|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
* }+ P5 r3 f6 N7 b" M. U; L#include <linux/init.h>
8 | `. x/ `8 Y: m#include <linux/module.h> v+ | b. }& K! g5 Q) x
#include <linux/kernel.h>
4 w: g$ R1 K; H#include <linux/types.h>, p/ M& }: i0 x2 n+ ?4 Y0 N) d
#include <linux/gpio.h>- B7 k! p* Z. ?% ?3 t% A- {% k% ~
#include <linux/leds.h>
: u7 K2 c0 L2 n& \+ T- |: E#include <linux/platform_device.h>- e8 \4 N# s6 g( r$ v
, I! l, ?% c( x5 L#include <asm/mach-types.h>
; X# t/ `9 n, ~: B#include <asm/mach/arch.h>6 K2 X, w" S" }+ x
#include <mach/da8xx.h>
/ C0 w {0 |6 c. h" }#include <mach/mux.h>+ H! q, y: H) {
2 d; {: X* |; }# q8 `
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
* J$ t! e" f$ B#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)( C$ G1 g3 b% Q# Q
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)' X x- } w" T# Z; E( g
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
: H7 _; m% E8 ~, U
; V, j" c+ r: ]" \& v/* assign the tl som board LED-GPIOs*/
% a3 \% Q; ` }" d$ Q- Vstatic const short da850_evm_tl_user_led_pins[] = {8 `2 C6 u0 p% o1 k4 d
/* These pins are definition at <mach/mux.h> file */4 _3 U; W5 I3 u7 v- }. N$ L
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5, x( C& v: R/ p8 m
-1
! G6 ~9 V3 {$ q1 E% _; }};% z! z5 b4 A" E3 @0 p: h: l$ \
) ^3 E5 [) q- A6 e. estatic struct gpio_led da850_evm_tl_leds[] = {5 w" x" p+ E& S! w# L0 ~
{( M! a5 @$ j7 H
.active_low = 0,
9 L0 L. b3 I* z, C' g: U9 h .gpio = DA850_USER_LED0,0 o2 B$ N+ i) m7 @) E
.name = "user_led0", l3 b( y7 D- w5 o5 @( m) k) K8 t
.default_trigger = "default-on",
J$ H$ b+ i4 S },4 w: l4 l( B) u: S/ M; X* k
{
: ]0 e" {! m8 Q5 @9 I% W* R4 w .active_low = 0,1 a" m0 J* s0 b, @
.gpio = DA850_USER_LED1,5 K+ a& y h) \6 E4 E& \
.name = "user_led1",7 n/ @9 i: k) Y- j4 [. ?
.default_trigger = "default-on",. Q7 ]' I$ H0 X
},/ [8 f8 J- j7 J0 }- G( c0 W
{
! S& \! x8 L, A$ t9 r .active_low = 0,8 R& y( I3 Y7 g
.gpio = DA850_USER_LED2,! C, C1 Q: d' Z) o6 p* g- I: |
.name = "user_led2",
! X% l H" ^3 `/ K' l .default_trigger = "default-on",
% I1 _+ G- p' p# E) E },
! f5 h+ c1 q% L" p M6 W' ~8 ` {
, N( j, A& V* L .active_low = 0,
; s8 M1 e1 L; v w0 e .gpio = DA850_USER_LED3,' G/ d- u& P; p( K- G9 h
.name = "user_led3",
: f% ?7 r$ D- D! H' ]; R4 w, j& s1 s6 ` .default_trigger = "default-on",
& D; A) _, \* W* U },+ H; A: j7 W9 o6 |" U# s
};
8 _" f) v( T0 e4 y7 v3 r1 B# D4 |6 S7 [3 s& j! A
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
: H5 o* I* _3 @+ ^7 T6 P) U8 n) u .leds = da850_evm_tl_leds,; |+ z) F1 W2 E: @5 d) Q
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
" X$ p* {# X( q5 O" @/ \9 e};. e) d3 i: z+ ]$ R n
% X* d# d' r) d/ n& U5 H0 Tstatic void led_dev_release(struct device *dev)
. K8 F5 h# I( X8 {2 t2 ~{
4 l' v! i3 @, V2 ^1 ^) c0 y f: v};
4 n( p3 v F7 B7 Y( z2 [
6 V S. C2 C5 B6 }static struct platform_device da850_evm_tl_leds_device = {2 H0 o7 D+ f% A! P4 e" g4 f6 p
.name = "leds-gpio",
1 O7 Z! z# _' k+ p .id = 1,$ `9 a. v7 t4 c) ?9 t/ ]. T3 o
.dev = {* a# G; [. W. m! d( e- u
.platform_data = &da850_evm_tl_leds_pdata,
. |! x8 [9 X( [1 q4 }2 [" W .release = led_dev_release,
9 L( ]9 Q& M. O; r) L }" G- `2 f! E( u2 D
};
?: U% i* C5 e4 d+ ]* K6 d. N3 q7 R# ?( y8 u
static int __init led_platform_init(void)
0 X8 _% M3 z+ c) {7 y; ?5 \{2 t2 @4 x( E. p: q( {9 K! T; {9 i
int ret;6 C. K2 u6 d, H$ V
#if 0/ D5 T- }# W9 B5 E% x
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);' Y4 {9 }# P( W- t$ g/ ?! ]5 e
if (ret)
6 ?6 d2 _: D/ x+ `* o pr_warning("da850_evm_tl_leds_init : User LED mux failed :"& t; k% c) S, r4 p, k
"%d\n", ret);6 B$ K0 t, c* p2 Y$ w+ I2 Z/ x5 _
#endif# ]0 m# V$ c' M3 |4 c3 S( T
ret = platform_device_register(&da850_evm_tl_leds_device);0 v! W. M0 w! z7 f. Y2 }
if (ret)
9 H6 m+ P) A& l( q5 f% i pr_warning("Could not register som GPIO expander LEDS");
) r3 c! g% A% j8 I: _$ l ` else8 N1 A& ?# l) k! s: B* R% s% T
printk(KERN_INFO "LED register sucessful!\n");3 C+ {( H B6 A% W, c- {; s
7 n) F7 R( ~8 H6 e return ret;
$ P% T2 ?% a6 p1 v}
' P; d3 z# h. e1 N5 ]* {( ^/ D& n4 ]0 m4 a/ [- \" K4 S7 R- M
static void __exit led_platform_exit(void)" Z4 \+ X0 x; @" b" c
{
& B: C2 Q. M" i1 Z platform_device_unregister(&da850_evm_tl_leds_device); ~1 l' c2 x' X# L" Z1 G2 n
, Z% o. t/ j, y+ [8 ^6 y, _8 `9 ^ printk(KERN_INFO "LED unregister!\n");
4 J: Q" K+ }' J. E}
$ [( M J- z/ }; X, x1 c8 |4 a$ m! ?; u5 g$ b1 O4 Z
module_init(led_platform_init);+ a$ }: f) Y0 @! f x. x
module_exit(led_platform_exit);0 o9 t5 L& |: e2 R( X0 F+ x
. J, d% F& _# h6 V/ D" wMODULE_DESCRIPTION("Led platform driver");$ o9 n8 }5 f; a- r
MODULE_AUTHOR("Tronlong");$ I( V$ y& p( v/ e. o& M
MODULE_LICENSE("GPL");7 F, U; }. w( G* C, F6 U
! i, @3 {) q3 N3 u; ~6 I5 | |
|