|
|
求大神给下面的程序做注解,请稍详细些,谢谢。3 a) ?) M: j9 t8 X
#include <linux/init.h>
% p/ D5 d- L7 U# T, p8 m6 g. Y#include <linux/module.h>, P- Z+ i# j/ H3 F3 \$ c. X
#include <linux/kernel.h>6 a! {6 Q; z5 G7 S
#include <linux/types.h>
9 V, [1 o7 z* S* d2 x#include <linux/gpio.h>- |- c, O6 P" D# H/ N, M
#include <linux/leds.h>( [7 P5 j, Q2 a8 a' P* }& u
#include <linux/platform_device.h>/ p2 u, O+ V; K* `0 s, b6 e7 Z- r
) e. Z: Z" J$ V1 u# s& h" h4 Q
#include <asm/mach-types.h>
' @2 n* J5 e. S. N#include <asm/mach/arch.h>, H' J; a) B+ T
#include <mach/da8xx.h>3 V" _! I& m* T! n2 v$ R
#include <mach/mux.h>. J" H' L2 }9 m- W5 Y, ~4 G2 k
4 H" k `' W a C2 P#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
+ f& O3 y: m; |8 C, ^#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
& m" `# U Z" ` ~6 Z0 h#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
0 f+ |2 S% m# T, f#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
2 H' v( Z$ K# g: \% u' D' D7 T1 {9 W
/* assign the tl som board LED-GPIOs*/1 s5 u8 g- t6 O j: ~; B/ ~
static const short da850_evm_tl_user_led_pins[] = {
* l* U5 p, ?! e* J /* These pins are definition at <mach/mux.h> file */: W& @7 s7 `# \8 o9 C! z( b; j$ J2 X
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
3 f" v( t+ q6 k3 h2 a2 V9 } -1( ~$ C5 m* i/ }" Y7 `
};
7 ?2 u+ Y. `. Y. v
3 `+ z) g k' Y0 G- G0 Dstatic struct gpio_led da850_evm_tl_leds[] = {) n; q6 c$ u6 A: A+ i5 l/ i/ I2 k+ _
{
* [; I% v" g6 r( R1 E% p .active_low = 0,0 Z* O+ a: S& e
.gpio = DA850_USER_LED0,) n. ~# q: @9 |) ]
.name = "user_led0",
6 j, n9 b! Q! S# c! E9 y .default_trigger = "default-on",
$ ~3 y3 }, g$ z9 R },. b" O9 J$ Z+ U. q P+ p
{. Q( Y- |! G+ Z$ }6 y3 |' y% V' ~
.active_low = 0,
m3 V6 x* \1 ]5 u4 y0 } .gpio = DA850_USER_LED1,
/ }" [; ?: @+ z3 ?# Z. ^2 E .name = "user_led1",
( v5 O" X! ?8 J! i/ \" x .default_trigger = "default-on",
8 M9 { ] {: N },* ]. _* L- d8 O
{ J: M( j. E, ?& Q! T
.active_low = 0,
6 q. ~4 T) f! d, b& u7 L6 J0 ^ .gpio = DA850_USER_LED2,
6 k" J0 d7 B6 f+ { .name = "user_led2",
# _4 `) f3 A! x: k7 v# u& r .default_trigger = "default-on",
- w. C4 o+ w3 D+ |7 W$ I },, D5 g- F% c8 W8 S- S
{# ^+ O4 k* {/ I% I6 h, |( e
.active_low = 0,0 X- \+ ]0 b6 i
.gpio = DA850_USER_LED3," U5 H1 M) b; P- f0 d& O
.name = "user_led3"," b+ V0 O5 Y# ]
.default_trigger = "default-on",! `1 d1 h1 c5 n# l
},
; v( D$ U f* E0 ]3 q! P};' C0 `$ o0 X2 J: o2 U
* _' P7 C9 x9 e- Z1 x9 Ostatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
* C* r' ?$ j& s6 p6 d8 n .leds = da850_evm_tl_leds,9 ? L8 W$ P( N V9 K+ Q$ a
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
6 M' a1 T$ m- i};" n7 ~* x( T; _/ Y" r% R
# [8 j/ C. M6 F8 tstatic void led_dev_release(struct device *dev)# \4 j0 {9 K/ A1 I' L
{
' G9 e$ [9 F4 v};( g- @' W1 p* e
, X0 `1 \ j6 a! ~! Ostatic struct platform_device da850_evm_tl_leds_device = {8 }. x5 g) ^) x. q
.name = "leds-gpio",6 ?, [+ s; i" J$ l% h
.id = 1,
* g: `1 M. F' U( a6 |- T! d .dev = {
" Q. t4 M+ n% Y$ ^( k5 q. y .platform_data = &da850_evm_tl_leds_pdata, `; Y0 ]) N: G6 p; a% d' ]
.release = led_dev_release,9 E" v& D4 Q0 \6 G+ j' O9 g: @
}
; x; b* R8 }# M& H};, C3 A: }' F. f$ P
* t& G0 }; O' M9 D" t+ m5 C+ D
static int __init led_platform_init(void)
6 E) } e8 b9 R _% \4 R5 ~{
' a# ^. u0 z) t) Z" G! p int ret;
1 C6 Y0 h: |$ ^* C/ W#if 0( }: Y# ^- h! ]) F9 P- W$ b: o
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);) k1 I4 ^! N& F+ o1 t/ ?/ S1 j
if (ret)7 k, `& T% Y( w2 x1 q0 ?# ^
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"" [" i, P# E5 h$ h
"%d\n", ret);" G: d; n4 C P3 y) b% A
#endif. N/ w+ F9 S$ L- Q/ j# _3 _
ret = platform_device_register(&da850_evm_tl_leds_device);
: Q, o/ z4 _. s if (ret)
5 z% g! C3 ^/ f+ q6 v, M8 H+ \6 n$ ? pr_warning("Could not register som GPIO expander LEDS");. X3 i! S# w6 m' H8 n
else
( |9 L4 ]4 m) b! B. J8 H1 l$ Z% b printk(KERN_INFO "LED register sucessful!\n");- O; X/ s; f$ h. D
& ]$ Z; {- b: o8 o1 B( l2 E
return ret;
/ p! m6 R" N- ?& [% C# u}7 H. n8 `9 N8 H
, q' \6 M1 L" {+ }# Y& c7 s2 v! z' f
static void __exit led_platform_exit(void). a6 q7 c0 R+ P. i; E0 u
{
# L D1 `$ D3 q% E2 i0 A } platform_device_unregister(&da850_evm_tl_leds_device);8 U0 |6 c2 G9 u
/ ^+ M, a4 x# a b; V, x
printk(KERN_INFO "LED unregister!\n");1 m0 h- `* d- Y! \% G
}
; y' g% `& s$ y8 l& ^, f: {! h+ V) G: ^- O9 Z. R
module_init(led_platform_init);- R9 W) U: \7 d( h
module_exit(led_platform_exit);- w0 p% p" d5 }& x, p
! \7 @! X# l' R# @% @1 vMODULE_DESCRIPTION("Led platform driver");
' O4 ?5 r+ N1 W( R: Z" O& H7 QMODULE_AUTHOR("Tronlong");/ C: Z) t" e5 L& D5 ]
MODULE_LICENSE("GPL");
+ f7 b! {- Z( C' N- [! L
8 S* ^( z1 v h% c- m; I |
|