|
|
求大神给下面的程序做注解,请稍详细些,谢谢。9 n6 {! n3 g$ M( y( h) X
#include <linux/init.h>6 P- O d& D ^9 o
#include <linux/module.h>
" q2 n7 o6 V! i) b# w#include <linux/kernel.h>( {( _: j3 U* `! q2 _+ m& c
#include <linux/types.h>
+ y r7 x$ J7 l- _$ z8 d/ W#include <linux/gpio.h>
/ E6 I8 R3 a" {: f#include <linux/leds.h>( H6 K5 p0 L5 s' u. X7 p. G: o
#include <linux/platform_device.h>4 @) |, b% L+ G3 |$ |; v
6 Q& q* W! ], f) @( @
#include <asm/mach-types.h>
1 t+ h3 y* G/ n; u# ~7 }( B#include <asm/mach/arch.h>
$ `; I" L) m( h$ E6 u4 @#include <mach/da8xx.h>
5 @/ z W% B4 H3 R* O% ]#include <mach/mux.h>; i8 i& F/ @! [
% A$ x* S$ m, l* T#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)* \0 ~/ z; V% u/ q7 i# B
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)7 l. h& b* O( t0 G
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)3 w1 Y8 ]; {6 }2 v) m3 d# T9 ]
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
* D5 K1 G' Q9 Y/ c* u; T- P& L7 d0 P; Q+ J& m$ y
/* assign the tl som board LED-GPIOs*/9 M8 u) S- S X+ z6 }* n, ~
static const short da850_evm_tl_user_led_pins[] = {, ^! O4 H# t. v! f/ z
/* These pins are definition at <mach/mux.h> file */
% O' o, _$ Y; {9 S* q4 V DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,& i+ s' t" |4 `
-1, w; Q' {3 s5 X2 }
};$ C! D& |5 F9 N0 Y9 V0 R3 r9 G
' f J, }$ @2 g7 N, D5 |! i
static struct gpio_led da850_evm_tl_leds[] = {& o" C7 @) }% T. V J; j( d
{8 S* f+ S4 K U! k1 {' Y" I
.active_low = 0,
( w% @) _! \ ]8 B( u. k( |; { .gpio = DA850_USER_LED0,
: U! Z- f, A2 |4 h .name = "user_led0",
: s, j- _2 W& |9 H .default_trigger = "default-on",
& k! L# I: E, J' c5 y# S },3 ^- J1 A( h$ [
{
0 k* L2 i( e$ [$ F/ i .active_low = 0,2 X+ D6 W* d. ]
.gpio = DA850_USER_LED1,+ L8 R3 }+ s3 x/ L+ ]
.name = "user_led1",
t1 Y; K( N& y .default_trigger = "default-on",& R$ D9 t" L' m* v
},
7 x4 \) \. ?4 ^7 F {5 t6 l& {! d6 b6 r. h
.active_low = 0,
8 v0 I( g, y4 F. M, d% V .gpio = DA850_USER_LED2,
, S9 C( }4 T) R; a .name = "user_led2",) Z% y% k I) J
.default_trigger = "default-on",- V0 J6 }* A! I8 w# y( Z b
},
' |# s6 h; p8 z0 U# {5 H {, w2 y: F1 I; X9 d) y
.active_low = 0,; P: V( }/ ~3 J8 W9 O' x# o
.gpio = DA850_USER_LED3,
2 m- H5 t |7 y& G .name = "user_led3",9 f3 M" O! d0 s3 X, X5 t1 ~
.default_trigger = "default-on",( k4 s8 u5 E ]/ y8 a6 [
},
( \( f& F2 p/ A) K' l};* M; c0 v, x8 r0 k
' p! Z9 z0 A6 _6 F- y( G: ]
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
4 @$ B7 P; k/ \: L w! D+ ^ .leds = da850_evm_tl_leds,9 c' }7 S! i" y. x& {
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),0 G7 O4 R9 v' |% a/ p
};+ _9 i! H, b4 ^& d
4 H% a1 C: a+ _! ~' K; C
static void led_dev_release(struct device *dev)
# ]* ?+ P/ S4 i% T) Y{
% D- t; s5 y7 P4 `8 j2 a};
+ `3 G: j& f r. e5 S5 w( ]3 i7 ^8 j! n5 Q
static struct platform_device da850_evm_tl_leds_device = {( h# w& F, l. y9 p- F
.name = "leds-gpio",7 u" N) B( u z2 t! |* X
.id = 1,( h) i7 u! o3 d" C
.dev = {2 t& r$ L7 d% L, t! ?
.platform_data = &da850_evm_tl_leds_pdata,8 K- A. j7 [* q: p9 o5 l
.release = led_dev_release,
3 j" Z7 u. [4 u }
4 r5 ?- Z$ M; z4 e6 M};
; `4 j0 P" M! T5 c8 z) c: I8 S. i9 Z/ b1 S6 ^
static int __init led_platform_init(void)2 r5 k0 H# l2 Z( {" X E7 ~
{
( ]3 z% n5 x& m. L& F5 |* }. z int ret;; w* {& l2 N5 G5 q+ G( e; C
#if 0% B3 \; V5 c9 T; F4 n
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
, H7 {! P- }$ \ G3 L) Z: p: u if (ret)
0 h1 Z$ S; w; O) M& o pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
: | d8 r( z4 |( a "%d\n", ret);
2 K( @0 u/ V6 s6 s- u#endif5 w1 w7 `# W0 |
ret = platform_device_register(&da850_evm_tl_leds_device);
" j' ?$ j* K4 i( C2 F# l if (ret)2 e. f+ Z9 ~) Z* B
pr_warning("Could not register som GPIO expander LEDS");( k4 a$ e# n2 `1 Y* J7 o& Z- l% c5 }
else, P" Z, O' ]. E! m6 _! ^7 w0 T
printk(KERN_INFO "LED register sucessful!\n");
& n- b4 J) i8 h# j* Z, F, U# _' G4 J; C% U c/ @5 x1 X+ [1 p [4 p
return ret;$ B9 H( V$ d$ O6 f2 h
}
/ A# w5 K" C$ o
& n$ @1 F( L: ^: J6 G, Estatic void __exit led_platform_exit(void)
) Y3 t8 t4 y4 S{
5 n% T& @& U" ]- D- A platform_device_unregister(&da850_evm_tl_leds_device);6 C& M" @! W& V6 Y/ k: j1 T
/ ], L1 K8 G2 Q5 Q$ I
printk(KERN_INFO "LED unregister!\n");) s, R4 P2 d# T& N$ @
}4 m2 s$ W, c |2 }, c
! Y6 M5 w+ p3 A" \module_init(led_platform_init);
* _4 T# I! Z/ E2 S. d! xmodule_exit(led_platform_exit); e. K! S' n7 n- e
% V3 F5 W9 f* j# Q
MODULE_DESCRIPTION("Led platform driver");4 `( ]: U6 ]+ j/ K
MODULE_AUTHOR("Tronlong");
! G5 f5 R0 J# E) c3 T5 D" kMODULE_LICENSE("GPL");4 o. y! d( p; g7 S$ ^. o
4 E% U, W* e6 k( k* L, T
|
|