|
|
求大神给下面的程序做注解,请稍详细些,谢谢。. G# s# G) Z" s6 \# n1 A& _$ U; S
#include <linux/init.h>
4 l: L' H, t& Q) E/ l% {5 ~#include <linux/module.h>+ }# N; a& p4 q; n9 ^
#include <linux/kernel.h>
' [# Y) l+ D1 h6 a+ t6 s8 A3 Z#include <linux/types.h>
0 O e& a0 u: s# u0 f#include <linux/gpio.h>
]+ T/ j8 \ J D1 G% R" F: ^#include <linux/leds.h>
2 n; y$ p: \, f( i6 E2 _4 ]#include <linux/platform_device.h>! O9 S5 e, F0 i8 ?
7 ^3 E0 Y7 G8 F#include <asm/mach-types.h>
: b7 M0 q) P' P& z# ]: M% Z C% q. f#include <asm/mach/arch.h>* |7 r' i; T2 x6 K+ i1 w
#include <mach/da8xx.h>% }9 ^, Y* b. D( J
#include <mach/mux.h>
) U1 |% z9 N( Y4 i0 T5 G, a" q/ @: }+ ?- @# s7 h
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0), J7 x4 M. F% K( b, h- H
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)' p5 C' s9 J9 v% D
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)+ e7 r4 T/ }/ n( V2 U
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
6 |4 y. Y2 W+ V* S; A
6 O" d+ v/ q! v/* assign the tl som board LED-GPIOs*/
* T) [+ h5 k$ ^- _% u- astatic const short da850_evm_tl_user_led_pins[] = {
, R( Y$ C7 c1 p b" p* D /* These pins are definition at <mach/mux.h> file */' o7 x* h0 H, I2 X1 v& N" T% e1 }/ }
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,' U2 I2 `/ U1 x' [3 _- E. ~
-1
( X. a" ~- O1 u) r4 ^9 U};
5 d" t& k+ V+ i/ u* _: y
# w2 t( W, {- b1 s8 y4 Y$ v( ostatic struct gpio_led da850_evm_tl_leds[] = {: j- c) L# K" i$ d. ]5 y) n+ @
{8 Y5 y7 H& @+ D! y- g0 D) ?
.active_low = 0,
; n% Q) V3 Q9 x n: c .gpio = DA850_USER_LED0,1 I0 v3 m2 C. \/ K5 z: }
.name = "user_led0",8 S" p9 [5 E& D/ k k! H G
.default_trigger = "default-on",
- M* ]+ [6 V4 U. ]' Z. a },2 v8 k" x6 z" W ?
{
M$ ~' `$ q. O g& o4 g .active_low = 0,
0 s& z- J* h* i+ G& p .gpio = DA850_USER_LED1,0 m7 }9 ~( J8 ^$ g
.name = "user_led1",! J2 p" b$ h7 v. U# G& S
.default_trigger = "default-on",
7 O% h$ [2 Q9 Z; F) q0 I },; Y1 n5 H3 n. O" j: |
{
7 `# E/ m! h5 ^" C .active_low = 0,
& {# T: m4 E' W .gpio = DA850_USER_LED2,; k8 L8 n& `& C* D [2 L
.name = "user_led2",9 R7 a. V- m Y- Z9 x, l/ v
.default_trigger = "default-on",
, d( n. ]' K5 `! { c- w( S },
. F0 J: O1 S4 _: `" T {
: r" @: V" a: J$ N4 e# J .active_low = 0,
8 C3 K: i. z' ]$ n a .gpio = DA850_USER_LED3,
# \0 D2 t- g8 Z3 U .name = "user_led3",3 v" p. a9 s9 \" F' R+ ^) _
.default_trigger = "default-on",
! {! J& w9 R; n9 n% p },
B# t! Q* n3 [3 w' F/ ?};
0 U# b7 B5 o+ |/ N3 e* W
- Z% P9 f/ T. [9 Wstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {* _- E/ G$ L, Q& l
.leds = da850_evm_tl_leds,
# L! C& n3 T& ^2 E/ p .num_leds = ARRAY_SIZE(da850_evm_tl_leds)," J: r9 b+ V; n d5 `
};
( j8 G0 W) Q3 c2 s0 x( Q; ]5 t( U3 B4 }% O4 k) [: \
static void led_dev_release(struct device *dev)6 t I; R$ I, z! h+ m0 O
{
% R( A, W8 G7 D" p! S1 u0 C0 N};( o6 a* c$ {. P$ z6 G3 |! l
6 X3 f4 `+ t o. s$ x: d2 _static struct platform_device da850_evm_tl_leds_device = {
5 f9 ^7 { [( u1 |# z5 b9 l2 j: h .name = "leds-gpio",
8 p' J" _/ O/ a( J1 \! T .id = 1,
* F. A/ J" Y5 k! B& R1 u: u1 x* M2 ] .dev = { f& ^8 Y! d7 }) K2 G
.platform_data = &da850_evm_tl_leds_pdata,* |9 d6 T, B6 z z1 r- f* _
.release = led_dev_release,2 W$ ^2 W1 x) w' Y4 |
}
5 H0 J, f* X% b& O( y3 T( p2 h};
( P+ y0 ]4 }7 K5 Z' f8 R* i+ x. M/ }: o
static int __init led_platform_init(void)8 ~, Z3 z( o& E/ x
{0 P0 x; Z8 s* g* ]5 v5 h
int ret;
+ z/ C1 J6 x9 m" U#if 0
1 _ O; d' d4 r J) {% r! s! h ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);5 |3 r% E7 U) T% x# a
if (ret)3 d" E& f, h8 V5 b- D9 o( G
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"% i! B( A. D9 ]$ ~0 E; ~! B
"%d\n", ret);
! q, f! u. q. q# d4 M$ M- _#endif. R* C; ?0 g: j2 s. a
ret = platform_device_register(&da850_evm_tl_leds_device);5 l0 S5 k6 g, c, x
if (ret)' }$ N& b5 H, F, V; a- R: v6 D; m
pr_warning("Could not register som GPIO expander LEDS");3 @* P T; I* \7 W# Y
else( [+ x8 q' u" b
printk(KERN_INFO "LED register sucessful!\n");
3 p( T Q2 D4 ]' P& ^3 `% D. S8 N" L% U$ y" u
return ret;
- Y+ S+ i; C$ Z' F/ B: _}
( X& C- A% g! |+ _! B0 ^" o! m
, e$ f( X6 b. D$ jstatic void __exit led_platform_exit(void)1 U& [( g& v7 g! p
{
. g) ] x$ u0 ~) |0 C. X platform_device_unregister(&da850_evm_tl_leds_device);
. P8 J7 a: ?1 i8 E7 G6 n* Q9 u
+ n* X) S9 S' V R printk(KERN_INFO "LED unregister!\n");
5 k U; N4 I' }2 l}
' `, p* e4 ?6 c$ T& }* M& `' p# j' E9 z- d6 G U8 p: |# t
module_init(led_platform_init);
! _# Z$ x! w9 d: @) {module_exit(led_platform_exit);! v9 m/ a- m' ^6 n* A1 J
" Q' O0 G& E- J3 AMODULE_DESCRIPTION("Led platform driver");% K1 R0 {$ O0 ^
MODULE_AUTHOR("Tronlong");6 I* y! h: s- u3 f( v+ u& S
MODULE_LICENSE("GPL");/ m2 X( T3 q, h6 _, V
2 F& W* R4 q* I+ t
|
|