|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
: D1 z2 x* R) F" O4 I7 y% ?1 d#include <linux/init.h>
2 W+ W/ s4 a4 `/ W#include <linux/module.h>; S- y; y G2 W& ^- U* m
#include <linux/kernel.h>
4 p e" T0 u* ]% r7 T7 h#include <linux/types.h>" U3 s/ Z0 _) \% g
#include <linux/gpio.h>
4 o. n- `# c1 t6 t3 Q#include <linux/leds.h>
9 t5 k5 Q) z: |% h) A8 J' c% Y#include <linux/platform_device.h>
6 R+ H- r' X$ M" O R
: j8 q/ Q; D1 P* Z1 p! ]* W#include <asm/mach-types.h>
7 I: Y2 V" Y: V: F" W: r#include <asm/mach/arch.h>; N7 D2 ^! t7 i
#include <mach/da8xx.h>
0 z$ p6 K8 S4 P: o, ^#include <mach/mux.h>' n! B# D o4 `; x
4 u( g* i5 {% ]/ J$ O#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)0 F) i4 B( w# e
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)1 B$ t1 L0 S, E" |( e
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)6 R' ?" {$ I1 M+ N! N
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
& | J5 t, e) d1 j( @) [ W/ h* S) H# f3 U2 C- u% @& A) x
/* assign the tl som board LED-GPIOs*/" B8 }; v4 j0 ^( g' u2 f2 d1 E1 G
static const short da850_evm_tl_user_led_pins[] = {
& o' `( P+ f" t- n+ Z8 [! m /* These pins are definition at <mach/mux.h> file */
, L4 L4 G" J3 g! c u# s DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
9 k, M7 P4 P A# z7 O -1
2 T ~: |- V, M, u- c};
. N% Y3 `8 E+ s6 [4 k7 \/ @, c
4 z t& l9 R4 r& K& \static struct gpio_led da850_evm_tl_leds[] = { Q: j. D0 ?% W8 W
{ Z$ o7 u8 Z B1 s9 j7 y
.active_low = 0,
/ a( e* D9 {# Q# J .gpio = DA850_USER_LED0,
" q' u) s$ y$ n. E+ L .name = "user_led0",+ |( ^; |% @) o! i4 h8 g+ J( `& |- P
.default_trigger = "default-on",& _$ l/ S, @7 S) Q: C
},! m: _8 k8 B/ G2 b, k" K _
{
# ^5 @$ \* N$ m. {+ f .active_low = 0,
, s0 E8 S2 V# f d9 ~4 ] .gpio = DA850_USER_LED1,2 O; R% W* {5 @2 d1 Z$ \% w
.name = "user_led1",
, p* M* `5 [1 U! d0 i& d3 K .default_trigger = "default-on",3 x O" u6 |0 X- |& f+ W
},. R. c0 Z' w( X4 N2 C/ P
{
]# D; j/ a: \/ ^# x/ t7 h .active_low = 0,5 A+ X8 A$ }7 F- d: x
.gpio = DA850_USER_LED2,
/ z$ g/ F& F/ B5 F) H( A% [ .name = "user_led2",
8 i# {' O$ |8 O& u! j, l# O4 p .default_trigger = "default-on",
4 Z6 m T; t: s7 a8 O5 Z },- K$ U7 B0 `# Y# W5 L% v
{4 t7 \. v" f' P( O1 J3 j3 L& ?
.active_low = 0,; @5 n0 d; @, c" v1 ?
.gpio = DA850_USER_LED3,; r) d) u0 W$ t2 b( m
.name = "user_led3",- f m( |$ G% g8 |7 C8 ]
.default_trigger = "default-on"," L( F$ t: [1 `; a) a
},
5 f% }( e `2 N" }" ~};" M. Y' i' i* d- y) T" L% m
' S. S# t0 U* [1 y9 t
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
9 q& a# Y; N- J [0 n .leds = da850_evm_tl_leds,
' W1 V1 t3 F+ B; B& ^ W .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
& N/ D/ b, s& \/ L5 O- ?};5 a1 m4 J$ M: F; |, m2 y
: }9 Q" A" R5 ~: \5 f$ r4 L) c
static void led_dev_release(struct device *dev)
: P& }8 t$ r. Z, c. O& ]{# a1 ]+ V$ K3 N9 t
};0 @2 i5 s2 z3 o2 g3 O; j
+ d% u4 B3 ]* @# |1 s+ x$ J/ w4 C2 |$ e
static struct platform_device da850_evm_tl_leds_device = {
' y1 x7 @9 v! Y0 o8 ` r .name = "leds-gpio",; i# M$ t) v ?7 Z9 v3 A% L
.id = 1,3 o9 {7 t A# k6 Z4 R
.dev = {1 r3 A$ l1 A* ]* s9 @
.platform_data = &da850_evm_tl_leds_pdata,
+ r6 m! X* a% |: O .release = led_dev_release,& U2 s6 _" I% r4 ^. a( _/ N
}" ^/ X: W8 A1 N! f# n& ^
};
! m' l% Z" C! s- A' e1 M! c) T$ N2 f) }0 W: |" {
static int __init led_platform_init(void)) E! m; _" v1 b1 _4 Z$ }/ I
{
- _: k* w* ~8 w9 D int ret;$ E/ U$ U1 g7 A4 a
#if 0
; E2 ?' w9 e8 ~/ s ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);: C) \: S. [! x* ~$ Q
if (ret)
) D( _2 ]8 U% Z" C) r. U! r pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
6 Y/ s% h+ ?: C0 h. P; s8 q1 Q "%d\n", ret);
+ e' j0 K, n6 Y" A& C! Q7 O, n- I#endif
, I# \2 D/ ~: M I ret = platform_device_register(&da850_evm_tl_leds_device);+ X; H- U/ x8 w( y& T8 A
if (ret)
, u5 E2 L3 p# s* K" w" R& [5 ~6 [6 | pr_warning("Could not register som GPIO expander LEDS");
# Y; g" e+ F& M' y else
) _4 T4 f9 s% C7 i- w, M printk(KERN_INFO "LED register sucessful!\n");
8 c9 f3 ]: v0 Q+ {% ~: e* [: t9 c! j+ l& c% w
return ret;
6 G! [( S8 t. w7 _# [5 a6 C9 ?8 ]}& M; h. M) p; y! M p$ G" \# O" i
# Y# A s6 o+ tstatic void __exit led_platform_exit(void)
; _( `' P0 R+ @7 c0 l5 G7 E{
3 D, v+ A( X& ?+ }, v platform_device_unregister(&da850_evm_tl_leds_device);
0 m( \" g: Q" p# j1 w7 X
c, ?; v3 T. w6 _9 w; ]! m( \ printk(KERN_INFO "LED unregister!\n");
# ^* m' ~3 Z5 g0 A b9 \}
; i" S5 ]/ }' h; m0 q& L1 ~5 E
1 s$ z- Y+ w" \/ Z) l" Wmodule_init(led_platform_init);0 O8 A4 Q) L+ G' I
module_exit(led_platform_exit);4 N3 ?6 Q! ?: ^$ U* e- I+ K# g% y
7 F5 y& e7 w* h
MODULE_DESCRIPTION("Led platform driver");/ J7 ?2 x, y' T
MODULE_AUTHOR("Tronlong");
# c& l; s2 l' t% bMODULE_LICENSE("GPL");) g5 W" G& U9 B4 k, a' @
5 H/ w7 ^9 Q* o! I, @( C2 {
|
|