|
|
求大神给下面的程序做注解,请稍详细些,谢谢。4 b, A/ A3 V0 Q3 Q5 d
#include <linux/init.h>0 ~0 T. N( H+ d0 `
#include <linux/module.h>& W; S |6 Z8 c% i( t
#include <linux/kernel.h>
3 h0 `$ z6 d( }, X$ e0 U#include <linux/types.h>
1 G; f0 A, y# J9 t#include <linux/gpio.h>4 @# n, @* ?1 b' i
#include <linux/leds.h>
: | L. ]" b7 J" O+ C" z0 G4 J#include <linux/platform_device.h>
# I& F1 \& M' j- y' {; y& u
4 h6 ^ n7 b: ^3 v5 t; D#include <asm/mach-types.h>% M, R' m$ A% L) U4 N, L
#include <asm/mach/arch.h>6 T% S0 }7 X. B) m5 v- p
#include <mach/da8xx.h>6 p) d; v# q: Y9 w# F0 }% V
#include <mach/mux.h>
6 U# W( L$ q8 W5 `: n
3 u) b2 z- V( A J/ A/ G* y. e#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
5 L$ G- m) [9 ]#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
' R7 z0 [. o# T& \#define DA850_USER_LED2 GPIO_TO_PIN(0, 1) @; s: x3 Q4 _( V4 Q3 k! R
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)8 G7 i% A8 n; u
4 r. I7 j3 S2 r7 @
/* assign the tl som board LED-GPIOs*/
' r/ @4 n* {# T$ r. j! Mstatic const short da850_evm_tl_user_led_pins[] = {
8 {% X0 n, h8 ? /* These pins are definition at <mach/mux.h> file */6 D0 F. o- h9 V8 ] V6 X
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,# e2 |/ b4 @$ R; M+ U+ E
-1
- ?9 V- G- E) X- b};
" R" C9 i x9 y; W8 u1 x }, F: }$ J# E6 a
static struct gpio_led da850_evm_tl_leds[] = {
" J& y2 A' W! U: V: Z" o, c; S* `3 C) T {) D( u& B8 ?: E3 n2 Z, h3 R+ s* T
.active_low = 0,' h0 o+ c! `* Y
.gpio = DA850_USER_LED0,
8 J, b$ E, p( J: p) u .name = "user_led0",
. b4 o& Z; W6 j1 E# s .default_trigger = "default-on",
5 \+ m( Z% [( L- t! E5 Q8 N& P5 Z( o },
" s& p2 O% l' ^! X2 H1 F {
& E) ~; S- s, C5 U2 D) e% p .active_low = 0,% S+ \8 [/ {3 `* E
.gpio = DA850_USER_LED1,
& V$ q' W. e( v( }. B8 a .name = "user_led1",
2 I0 |3 Y1 b3 {$ ?' N& z .default_trigger = "default-on",
* ~$ C9 X5 ~( Q2 q0 i8 u },
$ I' c3 F2 Z3 v7 W* V, x6 E5 B {: {' J- x& ^* e6 r" R4 N
.active_low = 0,/ |, ?, Y: b# G5 {7 o& @: M
.gpio = DA850_USER_LED2,
; Z5 D2 Q, S4 N* O& W+ `* C .name = "user_led2",
6 ~1 N* F1 j# e) x1 Z4 R/ { .default_trigger = "default-on",# C% h9 h! x7 r4 m; _. ]5 w& U
},
: f2 R1 [( a4 U, g3 a; N/ t8 c( ? {
* @& f6 l7 z' q5 ` .active_low = 0,( G/ Q$ y. ^# f
.gpio = DA850_USER_LED3,
" s7 z# ?" {6 Q, n6 n .name = "user_led3",) M5 \. J" e. C) B8 T
.default_trigger = "default-on",
$ d( \3 [% A8 N' T( z' E },
" H# a5 l- s: |' D$ m8 u* n0 K};
g+ S% Q+ J$ E+ c: h/ {0 C/ J1 I, E. `5 {( V: k
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
; D: B' E, ^. j4 Y! p .leds = da850_evm_tl_leds,
|# y$ W# P9 J. r$ m6 V M .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
) ^/ M! B4 R8 [) c. z};
: J9 J) L8 F v; E* S2 [0 C* {! k2 K
static void led_dev_release(struct device *dev)" l. t. Y6 L' t0 @& l+ l
{
! U5 w$ i) b. J};
& x- g8 H2 q1 p: N2 v: _8 S1 P7 \$ y$ S. ?9 n: X V7 z0 }
static struct platform_device da850_evm_tl_leds_device = {8 Y! M9 ^7 g* A4 [
.name = "leds-gpio",
+ [' P: y5 D) r( [" M) M .id = 1,
5 h* p+ J4 |! d, {# a- a- Y .dev = {
! m0 h! D4 c5 A2 @$ O .platform_data = &da850_evm_tl_leds_pdata,( H& B! A9 H. M2 N m
.release = led_dev_release,* e* Z- L _6 v
}
. A+ g Z0 c. `; s0 G; Q1 I* }};
2 ~; w* _( k& ~! l
; k! M! J ^, f( b W( G* Istatic int __init led_platform_init(void)
6 C) @; ?& t4 A$ X* [2 c{
* I. ~- ^! x. f; [3 |; C int ret;
* r+ o3 o7 Y# ~, {' G) _8 R& j# f#if 0
; K7 s& p6 O' W" I1 m ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
; j/ ?0 B, ~; ^4 ~9 c0 N R2 I6 X if (ret)4 ]% c m1 d; ]* _6 o! d" B
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
5 ?: a8 h1 Z" g! h2 H' L "%d\n", ret); B5 ~7 p1 B, y' D8 P# a$ d
#endif
* ?7 U4 L: c; e7 ~8 J: w7 T9 k ret = platform_device_register(&da850_evm_tl_leds_device);
4 x% u! k0 B( \3 @ if (ret)
- j4 r( b9 M0 S pr_warning("Could not register som GPIO expander LEDS");
! ?5 ~' z: s- v else
3 I) O! k9 }, M- w3 r7 c printk(KERN_INFO "LED register sucessful!\n"); A& a I$ L2 R+ I* v; c3 w" P3 h
3 x8 E6 r! H/ Y0 l6 y7 @
return ret;
1 c( v+ f4 s4 F' K% k}# u$ p- y0 b6 } C
( I& r1 ^' ^! n! j* ?- Tstatic void __exit led_platform_exit(void)
8 Y+ i! Y7 r- Y6 B5 [/ |- b{3 c; _4 {# D* W1 R* _0 U ^ ]$ g
platform_device_unregister(&da850_evm_tl_leds_device);
- A) K$ _& L) ~( w$ s. h# c2 d0 w( P2 y V
printk(KERN_INFO "LED unregister!\n");0 r* g6 B/ p: ?; ?6 L* S1 o" W6 Q
}
( E, z8 \) {7 K; I( ]$ S! l( U* M5 o A* l) i
module_init(led_platform_init);' C9 o5 S; h3 e" R; ^
module_exit(led_platform_exit);
9 Q e. k5 h/ v0 D; O
0 D4 l, o9 ^0 ]# [( KMODULE_DESCRIPTION("Led platform driver");
, C0 }) O: J& B! LMODULE_AUTHOR("Tronlong");8 ], |5 L: C5 S/ Z2 Q" Y- M
MODULE_LICENSE("GPL");
" u% v& Y5 {) h, W1 _9 ]( K
9 {2 \6 Y. w' h6 _! E" P; q5 ? |
|