|
|
求大神给下面的程序做注解,请稍详细些,谢谢。8 F% \1 r3 c7 U
#include <linux/init.h>
1 Z( V" ^3 q( V$ S7 `% ?, l N#include <linux/module.h>% H- x. l7 d. J. d$ T/ c; i
#include <linux/kernel.h>: E' z" Y: |5 Z
#include <linux/types.h>- b$ _5 g" ?- [+ t2 G
#include <linux/gpio.h>
- S0 \ D$ K0 W G+ j#include <linux/leds.h>
G) R- X! I2 O% m: A7 K; c3 A2 A#include <linux/platform_device.h># B0 q% D m2 N: ] V& U; {) l
9 _" w; Y, v# f4 X" F
#include <asm/mach-types.h>
, r8 k& d: {! V) \! R8 d#include <asm/mach/arch.h>+ i. g7 q6 P h. D; l% s) s# Z
#include <mach/da8xx.h>
1 M8 q/ b; [2 D' d5 ?3 A#include <mach/mux.h>
! o' v0 v: s/ a5 ?" G+ s7 Z& X6 B2 t" M+ G2 a, |4 d
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)& s. q6 p+ ]1 w: i& B- w
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
' a3 j9 R4 H* Z' A7 C1 ]5 F1 I#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
+ q" r [2 d" B& M* D0 H) u#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
( u1 i/ R' O. z2 C7 ]9 a4 c0 \ Q8 ^& T+ V) q% o
/* assign the tl som board LED-GPIOs*/
7 u7 n, }' b' Jstatic const short da850_evm_tl_user_led_pins[] = {
5 s$ g" M8 e3 ~7 X2 n7 \ /* These pins are definition at <mach/mux.h> file */0 I; X+ \( c# A$ @
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
9 n; I2 W4 W2 L5 c -1
+ i3 l( {$ `; ?9 t2 K};
]& i* h; |2 \- N( j
" K/ g0 I. Z6 I+ A7 Q5 A7 gstatic struct gpio_led da850_evm_tl_leds[] = {" ~' R# r) J- S( v0 o
{
4 L3 K O: h/ q! q, J' m3 X2 P; Z- ? .active_low = 0,
3 U9 U! |' `7 j; _- }; B .gpio = DA850_USER_LED0,, u& m: e S7 B8 ~2 J
.name = "user_led0",# a1 g9 j( K# r, m6 A0 `3 Z
.default_trigger = "default-on",: ?, W/ `7 k; R* i+ i+ L! g
},
, F% s6 \+ f7 j0 l {
+ ]) H. H8 O7 Q# {# L .active_low = 0,
. h8 ~& c/ K+ N6 ]& { .gpio = DA850_USER_LED1,0 l( G9 L% d' `9 d: I
.name = "user_led1",1 f6 z! |1 Z( A1 H% _
.default_trigger = "default-on",6 X) U( c) U) i' m% U$ k
},% Q6 _. k* j1 a8 K# Q! u+ P- @5 n
{
9 j5 g2 }$ \2 u2 q1 i9 C .active_low = 0,' c$ Y0 \9 @, I# C
.gpio = DA850_USER_LED2,
3 [; {$ i* H- Q .name = "user_led2", ^; j* K0 s+ y9 t
.default_trigger = "default-on",
7 |' g, I$ K5 @ },
4 i, ?7 k" o4 m- p# ?$ \ {
( |" L& C7 I* M7 J. y .active_low = 0,
/ y# O6 `3 u. p3 {. e( N .gpio = DA850_USER_LED3,
2 S+ u- a/ b% n. Y0 X [ .name = "user_led3",( L. \6 A/ c4 n) M! T5 z
.default_trigger = "default-on",
0 q/ ^1 ^4 F, o% o4 N# d; [5 k( \+ B0 W },3 j2 }. j1 C* ?' f% J
};3 I. U. {' b+ `8 C; u: `4 |$ v1 r' h
" F/ `9 A, b9 V0 `, j+ d
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
& |3 d3 ^, |+ {1 x3 P' c5 l .leds = da850_evm_tl_leds,+ Y. o5 G4 o) _( Y9 @
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
; y# k$ H1 I: U};& p# C; H. o) m" R) V* L
, q3 s5 Z; J: I; z/ {static void led_dev_release(struct device *dev)6 l- D$ B3 M$ U/ }; j
{
3 @( |& S. A/ y$ x" ?};
; J7 B# y; I% y* H! F/ }4 q: f
* u9 E) |0 U+ _, H; v( |static struct platform_device da850_evm_tl_leds_device = {
; l4 l0 h' [$ Y2 {! U% e .name = "leds-gpio",4 v3 p d, z& w. m) Y3 o
.id = 1,! p! H x' i/ A
.dev = {
" y% w5 K2 g( j# z .platform_data = &da850_evm_tl_leds_pdata,8 @' n6 P3 U5 n
.release = led_dev_release,' s1 K7 `. U) G) W" R' z
}1 {' A* T" M4 K' e' T1 @! P5 {4 v
};4 o4 B ^8 `! `4 ^+ P. u. S% \
" ~ k Y8 s0 M2 { dstatic int __init led_platform_init(void)2 e9 j+ |. { w: S; S7 I: Z
{
, P! [1 U3 i! U" Y1 a i0 k int ret;
$ M1 R7 \$ M8 f2 N& c$ d; }#if 0
) b4 S+ V2 v4 g* x* `/ u: g1 s ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
& r. |9 H. J- D$ h6 P if (ret), T1 F3 c: l, K
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"3 ?& L; G. y3 B' {: l* g
"%d\n", ret);
" |. b$ ]' T! j) B" b0 m#endif% u q, c. y* O% W; H9 u1 `
ret = platform_device_register(&da850_evm_tl_leds_device);) |, e Q$ U1 K! n8 y k7 v
if (ret)# Y+ V% c% m, {% P
pr_warning("Could not register som GPIO expander LEDS");
& o) M* I: P# a$ v7 h else) `3 p# m# Y/ c3 w
printk(KERN_INFO "LED register sucessful!\n");
# e' J( r: P& F. d& d6 n7 G: A
9 g# |7 X" O& ~9 O5 e* ? | return ret;. _" f. \' g2 }! l
}+ e" Q' a$ m1 G7 b
^0 w/ H& ~1 }5 sstatic void __exit led_platform_exit(void) P# A4 X2 M! p8 J
{
" r% L) B% {- |8 G5 A1 w platform_device_unregister(&da850_evm_tl_leds_device);
- d( ~% L" J* s4 I. c8 y$ z2 W5 H
printk(KERN_INFO "LED unregister!\n");
q5 V% j6 A1 }) y* Z( |, o}) d7 s: c' V' l
; X, J" a! _+ N- F' Mmodule_init(led_platform_init);. p' M6 m. Y1 n1 K O* ]8 y
module_exit(led_platform_exit);
: p- }+ W% J! E4 L7 C
4 q& E |7 k; ^8 qMODULE_DESCRIPTION("Led platform driver");
8 C |5 x3 o( u% J D& i: UMODULE_AUTHOR("Tronlong");) L- ^( x$ [1 t# Z7 }
MODULE_LICENSE("GPL");+ o2 h* o4 F8 N. Y
u: ]4 C+ f! Q8 U7 x |
|