|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
- s6 j9 X- y7 ~/ ^; I#include <linux/init.h>
& t5 m+ L" M0 v; q#include <linux/module.h>
+ Q, T- U$ N2 N3 F) P2 P: L: w b#include <linux/kernel.h>6 k+ j, {; x3 Y' L
#include <linux/types.h>8 k0 \; u. k7 x' [. K
#include <linux/gpio.h>
' ?/ W" o3 ?% Y" u' u#include <linux/leds.h>5 ] W, v0 ?1 @- h! ^: `
#include <linux/platform_device.h>1 l1 h% m+ ?9 O+ I
' G" d" M z/ Y1 Q5 R7 y
#include <asm/mach-types.h>
- J( ]! Y5 r: F3 K: n# A' ^2 l#include <asm/mach/arch.h>' a3 u4 j' Y5 Y1 r5 f
#include <mach/da8xx.h>
( M4 {: x- F9 n0 o3 n9 H1 g( B#include <mach/mux.h>
: Z$ O" |8 o% F: W, }; ^6 h, e/ {% H7 F5 J
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
, G7 d6 `, Y5 w8 A' e#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
* `. d- s( z) @+ P. M#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
4 u: M! V% R! I# n: w1 O#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
2 ~9 d/ h/ h% P: h: H+ ]7 [8 u n$ | j I9 ?
/* assign the tl som board LED-GPIOs*/
. x) _* D# M1 \static const short da850_evm_tl_user_led_pins[] = {
) `' U$ D3 L1 g) s9 n! f% m* Z /* These pins are definition at <mach/mux.h> file */4 s* J" i7 d4 y# M$ Q2 ~
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,, i; a+ z6 V) D, K* u* H+ T
-1
, u' {% @. H" r) a! H};: E6 v5 |( J( O& W6 `# V
$ {3 s8 T- n4 }) \4 `# f6 X/ }
static struct gpio_led da850_evm_tl_leds[] = {; Z y; ~6 P0 F: E) \: ?
{2 x; |" W# I% l# u0 D0 m7 G9 u6 I
.active_low = 0,- p0 ?, [. E. {% b6 b# {
.gpio = DA850_USER_LED0,/ f) {7 o: c8 h; _4 B8 g
.name = "user_led0",; O2 k/ T' k0 w
.default_trigger = "default-on",
' @# t, U# a* Z3 U },
1 S' l) n: g- R* ]6 ^6 O, D2 i* \ {
' C# b- Y& h0 R% k .active_low = 0,
# K, ^* s2 y7 E9 g! L& X5 b .gpio = DA850_USER_LED1,
2 g3 D* \; B: e; T' c' j .name = "user_led1",3 [% u ^1 d: O
.default_trigger = "default-on",
0 m5 a, K* A- n, _4 G4 G) R( k2 s! l },+ X7 x- u+ J4 f+ A2 l
{# F6 k& H* Z0 t( E+ T
.active_low = 0,8 B/ a3 P1 D# {$ E0 v- D* F
.gpio = DA850_USER_LED2,8 g+ X3 n _) p* J( z
.name = "user_led2",
# S" d# a9 m! i& X" u5 K4 m0 a .default_trigger = "default-on",
; C5 h# n7 W( Q },
& O O) E0 P& \, t {
0 f0 n4 }9 x8 ^ .active_low = 0,
V% y" J% s+ f) O: W+ X .gpio = DA850_USER_LED3,3 k9 G; z2 G, C( m
.name = "user_led3",
) ~, ?# Z& R; o# j4 R* `9 |6 W .default_trigger = "default-on",0 @- }" H$ z# R1 r
},
8 R8 C, x3 w9 x};
: r' s: p, p6 M
/ F3 \" P G1 N' N, `static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
. w8 c! J0 T( F .leds = da850_evm_tl_leds,3 [. u! y7 P4 ]- h8 O. O+ I. L
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),- Y* V/ x7 t5 z- |
};; W+ {8 ?" Q" i- ^: }5 _9 m/ p9 b8 C
1 S) P* U" S+ X1 c4 P8 Fstatic void led_dev_release(struct device *dev)1 y) F* g/ P( r$ j) _2 E- B0 Z
{; ~7 c4 S" n/ N0 R4 {3 E3 y% L
};& ~: S" Z, v4 d2 {. i* ]
/ c0 `2 y ~4 S# i4 ~; ~ s* p8 n* o2 ostatic struct platform_device da850_evm_tl_leds_device = {
6 H; C, J2 E. Q: Q% K& [8 p .name = "leds-gpio",
# i8 b( }5 {# N. M! P .id = 1,
. Q& `" B/ K3 `' F! y .dev = {# o3 Q5 {, S" z& H( }
.platform_data = &da850_evm_tl_leds_pdata,
0 @" G( X) u6 E7 h6 U! O0 C# Q .release = led_dev_release,5 ~( A9 i2 X3 V( Q3 u
}/ L4 Q, v: i# o6 Y. A, w" b' o( o q
};
5 @+ m( h6 {7 e+ X" L+ m L8 f- \/ M# B
static int __init led_platform_init(void)$ A; j9 i/ `* E2 y
{0 l2 {' `* i" f7 o+ h. a& U+ X
int ret;
. {2 |3 y9 G4 n4 V: Z3 v, h#if 0# z, |& f1 J6 @. F6 |
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
2 e0 a5 s3 H# ^' Q, I if (ret)
5 q3 ?, w5 h; |$ `& _ pr_warning("da850_evm_tl_leds_init : User LED mux failed :"1 t9 F8 l4 M, A5 k: L
"%d\n", ret);
* @3 Q% Q4 _" A#endif, L7 q J" N5 p$ o7 ?% z8 h
ret = platform_device_register(&da850_evm_tl_leds_device);# Q% H& v$ ]+ P8 U U( y
if (ret)( c$ [" i" ?& K; Z+ r! T, r
pr_warning("Could not register som GPIO expander LEDS");
! w5 t* S" f: o- J6 \ h6 V else' r( v0 ?& S' h" Z: o" o
printk(KERN_INFO "LED register sucessful!\n");
4 W8 q( [* c3 q4 k; ^1 L" z! P; C! ` t. n8 V1 a# `% q
return ret;5 y+ T1 c3 f8 q# m
}' q( `! y# v2 I J- A2 z
* g2 A. B$ x7 {
static void __exit led_platform_exit(void)' S* V" @* T& K/ M+ R0 ^
{
) Q r3 Z1 y h' D! w- ~ platform_device_unregister(&da850_evm_tl_leds_device);
3 D. s6 t, Z* Q# ^7 g3 R
5 F7 K$ m2 G* r' G printk(KERN_INFO "LED unregister!\n");
- E( M; ^$ U$ S. `* {2 p- y: O9 w: ^}
& l6 J3 Q: Z% S- e& v
W, `4 O# g- m6 y, o. `, k# ?module_init(led_platform_init);
: y: N2 [) L- Fmodule_exit(led_platform_exit);
2 a: E2 i7 E" a- ]! G
# N0 _% B: o( ~/ O2 F' }. Y6 pMODULE_DESCRIPTION("Led platform driver");
6 K: ]: m% X9 Y" `MODULE_AUTHOR("Tronlong");5 S2 J2 y* q# H( w+ L
MODULE_LICENSE("GPL");. k- l7 a4 j& E* ^+ i# n6 F
% X4 H& c1 z3 g! W' [ |
|