|
|
求大神给下面的程序做注解,请稍详细些,谢谢。) p9 j: M$ n, z5 ~6 l3 V
#include <linux/init.h>
( m% i& R: B) i! Z#include <linux/module.h>6 l' s7 @) i! P, m7 P1 v) l
#include <linux/kernel.h>
) D2 m1 c- R. ~% A+ T#include <linux/types.h> c+ O1 k% r: x: g
#include <linux/gpio.h>3 W6 ~( ?3 m ^- F
#include <linux/leds.h>
( k* c. E# k3 V& u5 x2 ~#include <linux/platform_device.h>
) r3 R0 g7 R$ \6 U; C6 M
( Z) i$ K. Y2 {. H& T1 z- h' E#include <asm/mach-types.h>
4 e$ Y; o7 j+ q1 j! n7 a$ R3 L#include <asm/mach/arch.h>+ y8 J9 v$ X X) y* I1 @* h. t
#include <mach/da8xx.h>
( S6 d4 C. H4 ^& T" b+ ~' q. V#include <mach/mux.h>
( a! ^0 M' e e8 I, j! Y
) J) x' C# m$ P& p! s#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)' h# ? f1 \8 \6 ]" f4 j( j, q
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
# j1 S5 T( `. b: t9 `' R% }#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)# b5 A6 n F4 ]- f" t* s" K- ]
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)1 M9 Q$ ?3 G4 R
" s9 L, X3 \1 b; v
/* assign the tl som board LED-GPIOs*/
4 f I. i) x1 C* m( C4 Dstatic const short da850_evm_tl_user_led_pins[] = {
! K# k/ f2 ]8 u& M. D5 C1 T5 Q /* These pins are definition at <mach/mux.h> file */
: M- |3 }& z4 ~0 F1 E DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,1 q/ W8 o6 S3 Y9 R
-1
( p/ ^& [6 z4 q1 o/ T};
- H& n3 L: D2 |4 t. k
+ I$ E3 y8 J) @, J; {static struct gpio_led da850_evm_tl_leds[] = {
0 |. h, J) I2 I% M! N' s$ v {
8 L5 P- Q U2 B( H" e2 @0 G/ p* E .active_low = 0,3 O* z3 l, v0 F. {; C& Q7 ]
.gpio = DA850_USER_LED0,$ B, l$ R$ Q* L
.name = "user_led0",
, k( W) h4 k0 _; X, x: l .default_trigger = "default-on",
. I) \7 h; A! x4 j. k& F },
# n4 o5 W8 a: }; [* E4 N- P {
3 k4 S i9 x2 o5 G6 Q9 o .active_low = 0,% A9 v5 \7 s* u( j9 u+ ^
.gpio = DA850_USER_LED1,7 h# N( s( y' }9 ~" ^( | k/ c
.name = "user_led1",
1 t& u$ f2 C+ t: B- N .default_trigger = "default-on",
1 t+ \4 V- R# \# r9 f! A },
" i4 J7 }- f3 a% T {6 [, f4 r) z9 g5 M9 d" ]& u
.active_low = 0,
6 z) n1 ?' K. c& } .gpio = DA850_USER_LED2,
4 m: j( ]5 I9 N .name = "user_led2",% C3 d( ~# g) A8 j
.default_trigger = "default-on",
. G8 x+ X9 v! ]1 k, ` },
/ B; c. S: ^' l5 U/ x+ N {
: j: ~3 O2 F/ A# x .active_low = 0,: z X. @6 S2 d9 C
.gpio = DA850_USER_LED3, H' t, o. g! b
.name = "user_led3",# x! j. u* J& b3 b
.default_trigger = "default-on",
( r! {4 I8 P4 c( H! V },
7 U5 H5 _5 i+ E+ U};! Q' w5 O# Z4 y8 G$ Z! e; y. h7 I
Y( m$ ~; f4 ?6 X+ t
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
, e: h i4 |2 H .leds = da850_evm_tl_leds,
; k6 W( @% r t; z @" |3 n5 Y1 I .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
7 Q$ C+ \) J+ x/ K0 r1 m1 r}; u) ?; {1 g9 B x
5 y& @& o5 Z/ ^9 [$ E
static void led_dev_release(struct device *dev)6 f0 D% v+ [# g, t& `1 e7 `. E
{! _, [8 k6 R$ C# y+ J) R
};- n; Y O( p: H/ E2 V3 f
5 V4 A& l0 \1 H& H8 }# I
static struct platform_device da850_evm_tl_leds_device = {
* Y# J5 e* \: u .name = "leds-gpio",
/ o* a& y( @6 g0 O .id = 1,2 X" F" Y" |) C% `5 ~6 ^% L3 O
.dev = {: L" h9 Y! v6 i3 H# g1 F, _. U
.platform_data = &da850_evm_tl_leds_pdata,
6 g) w$ F. F6 J: @ .release = led_dev_release,- \- L! y8 E+ Z/ b* S
}
2 {6 ]3 g( B z: `};
0 Z8 i, @! G6 m# p
- p9 n* \* Z4 z3 Ostatic int __init led_platform_init(void)
1 O% w" S2 k: k) O! \4 n9 U{9 ^7 [3 X" o! N# o4 S! C$ \ y9 H
int ret;, n3 T" a- X2 k. K. {
#if 0
% j+ K, E- X- m) a Z ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
3 j# i6 {' m. B if (ret)" ~/ w$ t8 p" X* ?* l7 p. |
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
/ l2 M3 r9 w% ~, V "%d\n", ret);
' i5 p, B; C# ^7 T& Y W#endif
3 g4 M! {9 K1 Y4 H- i ret = platform_device_register(&da850_evm_tl_leds_device);
/ F5 n- V; `3 d' l1 g if (ret)' P- G& U* j L/ c& b! k
pr_warning("Could not register som GPIO expander LEDS");% L0 U! ^- D" z7 R R* W5 g! ~4 F
else
0 s' ^% N8 F0 N. C# [- K& f printk(KERN_INFO "LED register sucessful!\n");+ E& s) G& _- Q. P
) d1 t0 X9 t# p" s9 \9 O return ret;
6 g2 Y" w' ]/ |6 J% F/ k9 Y: r' ?6 K. p}
# Y9 I5 {) k* j; x* a. R6 W; K, Z0 N4 P8 v- g/ b3 l' N4 k
static void __exit led_platform_exit(void)
- N/ u. ?. H( @; i1 Y) r{$ i4 m) Z4 g4 n$ c" B) f3 ~
platform_device_unregister(&da850_evm_tl_leds_device);
- W' z. u/ l0 `* I9 v0 A1 l) ` e+ K9 |0 ]8 ]- _. @% a
printk(KERN_INFO "LED unregister!\n");
, y+ H6 y k: p# `$ D6 Z6 ]} a1 ~" J! c5 `5 F9 @& Z
& h' r3 a) |; q1 _ E& R3 Rmodule_init(led_platform_init);
5 y8 h8 }# h% I$ S: Smodule_exit(led_platform_exit);& b) i' o2 |" T' E! Z6 X
, P7 T' U/ B+ o- a1 a
MODULE_DESCRIPTION("Led platform driver");
; C- w6 g' V2 z/ B9 @; qMODULE_AUTHOR("Tronlong");* {5 X/ ]: x' y$ N4 t8 w9 ^
MODULE_LICENSE("GPL");% W! ]3 l! b. O% }
" V# p0 n1 T( I% y( r/ x! n! c
|
|