|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
2 @2 _% h! |/ ?7 U#include <linux/init.h>
' q5 T9 E! W- z; n2 G#include <linux/module.h>
; ]( {9 X3 O) [9 K! s; p4 _- h#include <linux/kernel.h>
; r, y, Y8 Z' w* `#include <linux/types.h>
( R, j5 k7 U) N% t#include <linux/gpio.h>* J6 A0 W' k( b+ l0 f
#include <linux/leds.h>
4 G3 d- D& h) _" A& }#include <linux/platform_device.h>
3 W5 D, T9 W Y; t i3 Q1 x. f. @
* X5 `; I" e0 t0 l#include <asm/mach-types.h>& O6 J% ]& u0 t( }4 m3 z
#include <asm/mach/arch.h>; y6 H% [: T4 t- a& M7 ?
#include <mach/da8xx.h>
$ C) {0 H, r& |! `% K5 t! O#include <mach/mux.h>; m& T, `( B2 I1 {
" p2 w, _, |# n% v; H0 @/ K
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
. J8 ]- w; l( m' c+ y8 k. m: f#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
3 b$ u8 K+ T: O, ?#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)+ \1 ^0 o6 Z, }
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)6 T; r$ |5 T W6 M+ k! X7 L
. s9 z# _5 O/ F! H7 A
/* assign the tl som board LED-GPIOs*/
0 H6 x- l ?4 xstatic const short da850_evm_tl_user_led_pins[] = {0 \. [3 e; D p. W$ |; Z# F" F
/* These pins are definition at <mach/mux.h> file */& A3 n8 i' L; a. Z }
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,/ @/ z0 {& W3 ^+ A# T$ p# a
-1+ n6 E8 ?2 A6 E% C7 B7 |: N
};! d4 G3 x+ f- B+ l/ M4 K9 v
) v/ M) o$ X: c' U3 F, U# Jstatic struct gpio_led da850_evm_tl_leds[] = {' }. T4 c5 X+ t$ f
{; X* x" u- W" T6 l8 \
.active_low = 0,
, v% n7 I# K/ |! \% a+ Q4 E .gpio = DA850_USER_LED0,: i5 J0 Y( D. w6 F, S" v9 T
.name = "user_led0",
' P) |- n- F" |0 { .default_trigger = "default-on",- j5 }# `- ^. l% v' ^9 ~
},
- l) _( F" D/ n* @. q. @ {
6 X$ l& |. M l w0 n5 w .active_low = 0,
2 U/ f+ X6 X2 ^5 r% W" P) t .gpio = DA850_USER_LED1,
; g/ l; w" f+ D. {6 z .name = "user_led1",% h8 \! _7 X* C4 I1 J7 D2 |
.default_trigger = "default-on",
: t! @- V) M5 E8 h },
% o( f3 G( s. F8 I {
, q" B' u6 v. Y" h0 o .active_low = 0,
6 Z1 _3 n- D- l. A9 q .gpio = DA850_USER_LED2,* g, P* N# M/ X' g# P
.name = "user_led2",3 v% L3 G% c* ]6 o9 B
.default_trigger = "default-on",
4 }: |" c( I2 Y' z! g },9 d* e! \3 e J+ G0 Y7 c' G
{
+ Y" r; A) ]& z% P, A .active_low = 0,
1 M+ E: U5 P% ^& Q) d( f2 \# ~ .gpio = DA850_USER_LED3,/ R) h( Y6 A4 A" x9 E0 X
.name = "user_led3",* K- |3 m' A8 e3 \" T6 i) c' Z
.default_trigger = "default-on",1 O* u# @+ {3 W/ `
},1 A$ Y( h/ _: Z2 R' X$ N
};" q9 u6 `. g( t0 Z! g% [/ S
7 {8 J7 p* j: w8 j/ C$ ?8 q1 |9 Vstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {, j* k1 }0 C% O/ [
.leds = da850_evm_tl_leds,
r7 V& x7 b: c! f0 w .num_leds = ARRAY_SIZE(da850_evm_tl_leds),' G4 v0 K0 \! Q/ D" |5 j
};
0 k4 X9 H( ?( Q/ E: e: l7 n& r7 v0 {5 j T E+ b' Z8 Y3 R6 `
static void led_dev_release(struct device *dev); S, P5 e2 t0 w F
{
5 i" C+ f3 o% ]0 q; j" v: k5 n};8 p+ e" H- `* H+ Y5 q0 C/ ]
& q# I5 V' T6 g& z
static struct platform_device da850_evm_tl_leds_device = {* h, v- j0 D' b& z; T# _8 }
.name = "leds-gpio",' P8 W! e4 O/ u' x
.id = 1,
: b0 l% c$ Q/ k1 m7 O( e6 l' b .dev = {
. H& m8 ~* G: G2 F% ~ .platform_data = &da850_evm_tl_leds_pdata,7 m. n; L) U) {4 o
.release = led_dev_release,9 c* w* P1 E. C6 ~+ R. t
}
# h% o, i R% x/ M: T};# i- |; R, P* `/ J0 u i
; {0 _) r- M& E# Q
static int __init led_platform_init(void)
) I6 @1 R. M9 T! @. F, L4 i; ^{5 w, e+ q. m9 k; |
int ret;7 _, k/ s% N6 b) B2 a* u" N' E
#if 00 y6 h! O/ S7 C
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);2 W# F; m3 h! X/ z
if (ret)
- i6 S# Q8 J, Q* x5 S+ t3 h pr_warning("da850_evm_tl_leds_init : User LED mux failed :"9 c' T( M4 o( S& ^% D' M
"%d\n", ret);, w8 P8 T7 V6 ~4 {
#endif0 I7 b7 @: ^& G
ret = platform_device_register(&da850_evm_tl_leds_device);& m5 E& p. g" a$ X5 s% P) f
if (ret)
2 X8 [8 `( z- Y _) x& W7 p l9 c) y0 T pr_warning("Could not register som GPIO expander LEDS");
d: {9 ~. k4 N; G& A5 q else
2 j% q. p$ T8 N( V+ `: h printk(KERN_INFO "LED register sucessful!\n");0 e: y, e4 s H& X
. X$ `8 E5 x1 h+ K {# I( @8 M
return ret;: ]- y- o4 O; i# X2 x$ w
}
9 `% Y. n8 [' t/ H- N9 @1 y- [1 M/ ^& |' D, u; t- L, Z# f
static void __exit led_platform_exit(void) B, |3 y0 Z6 N" U9 B: K/ ~' h
{
" G' Y" m4 b* ?; ]; ? platform_device_unregister(&da850_evm_tl_leds_device);; S% K* q% z/ T9 H9 N
' m/ j! _0 U3 j) U+ q! Q0 ? printk(KERN_INFO "LED unregister!\n");4 N, E9 A( r, Y" b2 K/ Z% a+ c# w N
}1 U7 H; }1 E$ B1 @ m
8 F4 ?& z. ?' k6 t$ k2 e8 {2 G6 H) p) M4 ]- r
module_init(led_platform_init);
; J' q3 i( w4 |2 e5 Kmodule_exit(led_platform_exit);
( C, A! D5 ^! q& h: ]* j
0 H+ ~! |) X) k$ DMODULE_DESCRIPTION("Led platform driver");
, U7 K% \# H$ r1 B0 KMODULE_AUTHOR("Tronlong");
; j! V/ E+ y" \/ ?0 C5 U# oMODULE_LICENSE("GPL");
) F) g2 @ f! f, w9 q0 U6 ~$ J$ G) j) x/ [
|
|