|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
8 u5 S+ t/ j) o( W0 ^#include <linux/init.h>' k; C2 X* ?8 J0 Y' l
#include <linux/module.h>8 v/ `6 q9 U) N1 ^# z
#include <linux/kernel.h>
$ p: m+ ?9 ]9 x/ P+ H& |#include <linux/types.h>! g1 `: d* E1 B8 P$ _$ o
#include <linux/gpio.h>& r5 x1 P" ]1 v6 F( w8 G5 T5 p
#include <linux/leds.h>
5 {* g4 [# e, t* C: `#include <linux/platform_device.h>
* }2 m- j/ Q; l2 N+ _0 R
: n9 J9 ?3 V" u5 f#include <asm/mach-types.h>( ^( l7 P U& Z5 W/ h
#include <asm/mach/arch.h>/ a# [7 {; t. H1 a" p& D
#include <mach/da8xx.h>2 B0 g( u* X. T8 N. e2 f
#include <mach/mux.h>7 a2 r+ k" }+ P, S2 `
- z( |7 a [% N: ]/ v
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
: W# b& e" F* u; ^: I/ K#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
2 M' A6 s$ Q2 r1 a/ R#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)4 j v4 g0 A3 Y
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2). V0 F7 O4 \0 P4 f+ k3 ]: e
: W, k9 R! O1 G
/* assign the tl som board LED-GPIOs*/, K4 v% a; A8 g& ]7 y* f4 E: s
static const short da850_evm_tl_user_led_pins[] = {
, i+ f0 U# \, c# s' D /* These pins are definition at <mach/mux.h> file */
2 V# b% M5 @+ J n6 _ DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,* e: l: Q8 e) [. w9 U m7 G d
-1
# m3 C9 c# E" _};1 n& d) A A% w6 S/ D# D
, x8 q$ {6 ^3 V6 G6 ~/ T
static struct gpio_led da850_evm_tl_leds[] = {1 R: Y8 s# ]" G, _/ \
{
: ]/ i& U; v. d9 O8 F .active_low = 0,
, L3 ?2 D% K6 w2 P% q3 x2 N1 K .gpio = DA850_USER_LED0,
# j4 X4 T6 ~4 K9 T( e8 _1 N+ [9 S .name = "user_led0",- K7 u. c' u; W- m8 [; A7 K
.default_trigger = "default-on",
5 N* e# R. l; \0 a+ s4 i, c r },
: r# |4 y& z- S6 I) r {
4 p. L2 ]% N4 g* [7 f! d .active_low = 0,
+ ~7 n6 N& i' j% ^8 _2 f9 w .gpio = DA850_USER_LED1,/ [1 L1 @# ]$ j
.name = "user_led1",
7 E2 a2 G. b; k% O2 M, a+ K$ H7 ^9 p7 s .default_trigger = "default-on",
" j7 [4 E5 T* V: i$ b, [2 r6 _ },
, M; I( L; _4 F4 Q {
" a) ]' a" R2 z6 m8 x .active_low = 0,
1 ^% o+ F+ }5 V8 I+ I* Q* V: K .gpio = DA850_USER_LED2,
) C2 J$ c6 i, `* Z! c) K" J$ m .name = "user_led2",
* M" B+ D, U( w% @" F4 W .default_trigger = "default-on",
0 o+ k+ T" k8 g6 E# G/ [+ ~ },. i8 P# k" M" t
{
6 K2 ?0 F9 s0 m9 l. J .active_low = 0, U& { Q$ C, v
.gpio = DA850_USER_LED3,
( Q9 A" t+ T' E' O2 M .name = "user_led3",1 y s' r0 x+ }; L) p
.default_trigger = "default-on",3 c% F2 R H, s1 ?9 s; p+ N) w( V1 C
}, @! K# v6 |8 R2 V$ x& f" C0 a
};$ a9 f6 {: X% e& ~$ M
, i/ v6 Q( a' b( B1 A! ]* S! Y% H
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
! s5 A2 ~5 X# B' K+ M" N7 Q .leds = da850_evm_tl_leds,
) X" z' H+ n' | y) E! D1 ]2 R/ z) d .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
6 J9 P- G4 ]) f! Z};2 i Q7 K3 s7 g Z: s4 J( Z
* ]% R1 Q" x# y1 Ostatic void led_dev_release(struct device *dev)
0 }7 y6 n4 I' f, Q- A( D0 {& `{" z4 s9 n7 a- c$ ^# q3 f$ l
};
: X0 |8 e3 ^6 }" d+ v) _1 P0 R' Q& F6 X$ t, t& C4 _
static struct platform_device da850_evm_tl_leds_device = {
6 h) P% J0 C0 ]' K .name = "leds-gpio",$ |: n/ Y& N1 J$ m. s' u Q* D, ]
.id = 1,8 e4 d5 W8 |9 J k) j3 J
.dev = {
0 m4 \. D- E& B7 C8 y& ]! b* | .platform_data = &da850_evm_tl_leds_pdata,
9 e2 U) M3 r# W, Z+ n# O$ g .release = led_dev_release,1 h9 ]- k9 u* l3 q1 r
}
5 r& Z: G5 i1 O* m};, J; v/ h% |, \ b+ v
" p9 A$ H) V$ d _$ D) Lstatic int __init led_platform_init(void)
0 n/ G+ a7 Q# E' k{# M) b" Q. Q6 v8 z
int ret;
/ P& j2 m2 v7 J9 U$ c#if 0
8 f( X2 q; N: f; p$ l7 D ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
& z- v) N; Q* t. g" `; O" A if (ret)
" d b& C& k7 u2 s' Z7 v, \ n; x pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
0 @0 r/ C0 u+ l2 P* m4 u% H "%d\n", ret);3 H2 X* T3 [6 _" \. D. l2 @
#endif
i* w1 ]4 ^$ j5 O ret = platform_device_register(&da850_evm_tl_leds_device);/ T: J$ _, q5 w
if (ret)& J" u& L1 n j# y4 E: J: f+ w
pr_warning("Could not register som GPIO expander LEDS");
* l% l1 [+ _+ I( E3 O; d5 B2 j else: g( t- k S1 l; u
printk(KERN_INFO "LED register sucessful!\n");) s3 i% N$ k0 E' {4 s- h9 n# ]4 T
8 {9 h8 O- w* _* V$ R
return ret;
5 m$ `/ f) b/ ^: v/ e}# [$ N5 W& [ E1 U
@& v* z* L( L$ [7 v6 }3 `8 pstatic void __exit led_platform_exit(void)
1 i* M+ f! [/ D0 O; K( R{3 G/ M! R- g2 P; |3 e
platform_device_unregister(&da850_evm_tl_leds_device);
& x; C! l1 R" ]. r) A4 d b" t+ [' @4 D1 O
printk(KERN_INFO "LED unregister!\n");
0 |! C5 M! F; v+ h8 b6 C}5 P/ r6 @; }3 O/ ]
8 _* S9 m0 ?" o
module_init(led_platform_init);+ h$ A- { D4 t& ~) z- {
module_exit(led_platform_exit);3 g2 V" w/ d, q& u6 z' @2 t
3 `' i% c* w8 T- z6 i
MODULE_DESCRIPTION("Led platform driver");! K3 \+ l; e5 Q; z% R, `6 `
MODULE_AUTHOR("Tronlong");. P! T$ e, x. y/ Q9 s& T* {6 f1 m& |
MODULE_LICENSE("GPL");' h B' t! p8 G4 E
7 D D+ P% J1 j4 o2 N& g
|
|