|
|
求大神给下面的程序做注解,请稍详细些,谢谢。/ m* _ t- o* b; V, ?: ?0 [- q
#include <linux/init.h>- C$ x! o7 `/ v- G* s
#include <linux/module.h>3 _& I5 N. r& z/ A* P) r$ s
#include <linux/kernel.h>
/ s" j' ?' |' V#include <linux/types.h>
- r3 I K5 m2 h! P1 I. Y" p3 f+ p#include <linux/gpio.h>! L- U& ~1 _, E; T+ ?8 Z
#include <linux/leds.h>% \. r: E3 \- `+ {! Q3 V
#include <linux/platform_device.h>$ i3 e9 a# S- t- a! R
- R+ G; O' @, [, R: l; e1 x#include <asm/mach-types.h>6 \/ J2 g7 j/ s* e0 ^' I' |9 k; @2 |
#include <asm/mach/arch.h>" L# J7 ?! l: s! f+ R* p9 K$ b0 x
#include <mach/da8xx.h>
3 Q& X/ v, j+ R# J2 a#include <mach/mux.h>
" _. s- F$ T7 d1 I$ R* E) r" V6 M8 u
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
2 s$ H# Q' d3 A9 x ^) L1 I- ?#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
' j2 W* U; [2 J* H#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
: m# e6 Z( v" t# O W: F: w" q; u% N; w#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)% ^ _' o0 w; @( ^9 `$ S5 f* }; Y1 ]
9 f& G) l( g: V" ?: C5 t1 P/* assign the tl som board LED-GPIOs*/
1 h) J" |& E" R) P% Z5 Bstatic const short da850_evm_tl_user_led_pins[] = {; I) i: G4 g7 v% \: Q5 H! {$ K, H! x& x
/* These pins are definition at <mach/mux.h> file */0 s3 G+ h) p3 ]* R
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
- [& g) J+ |( z3 ` -12 ]' Z E2 o7 c) B& X3 j9 J; @
};3 l" I0 H- x5 g
4 u, q% }) s ^2 e4 j
static struct gpio_led da850_evm_tl_leds[] = {: T% m, t7 j* K6 l
{7 [$ T% [, y5 e+ j
.active_low = 0,5 k- G, K/ X/ ?( q+ P+ ^
.gpio = DA850_USER_LED0,* C+ B) y' n2 p8 x* q0 J' h' r
.name = "user_led0",
' ?- g+ j4 U+ w' v: c0 A* c0 u .default_trigger = "default-on",
$ K% H: ^% s2 B! l: b },5 q( a, C6 m* ^9 m$ U
{
5 @' _! o/ g$ }1 V .active_low = 0,
1 H1 Z$ v- o1 ?+ e) ]0 S! ? .gpio = DA850_USER_LED1,$ f0 A$ W9 u/ q, `
.name = "user_led1",
# ^: V |4 Z0 S9 B2 e: L. w .default_trigger = "default-on",. M/ A4 M, k& P- V
},7 g1 L) Q9 N4 ^. f) a
{; ?% F3 X H5 }; f
.active_low = 0,
m1 [, c1 R* t/ Q9 C; ] .gpio = DA850_USER_LED2,3 v# g" C2 x* F2 t! s0 u# Y0 |
.name = "user_led2",. X! k$ b& C$ ?+ O: A
.default_trigger = "default-on",- J; o1 ~ \$ g3 w. w3 I
},
- ~& a( Q. u. \3 x% } {
$ n5 l0 h; w. \8 i1 m0 z J .active_low = 0,
+ m' `" i4 {5 V3 g9 x, ? .gpio = DA850_USER_LED3,
, S% w: s1 R3 e3 f# K, \ .name = "user_led3",
+ ]! C0 a8 K: d0 r! T; [* r .default_trigger = "default-on",
0 r$ l4 S. w4 m* C3 c7 D! P },
$ c+ b4 N9 a" _% V0 z};! }3 X8 S( ?1 q8 Q7 H$ V
% W% w& w9 A2 C4 G" h' C. q% c! O
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {9 x+ c5 r q3 F$ ]3 y
.leds = da850_evm_tl_leds,
, E6 E% h, h4 P- b" m6 N/ N .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
# {0 ?3 H5 ^; q4 S, x1 S};; n3 j) a& }# T2 c; ^2 F! U
! [" T- F' A/ V% u% X" V5 ?
static void led_dev_release(struct device *dev)6 k& Z9 Y) S3 d0 M* B
{
: w g" \4 z1 I; S9 B9 U2 |. @5 M};
! p" W P7 |% `1 `0 @
& s/ K) i7 ?/ p& h( S; n( p; a6 m% Ustatic struct platform_device da850_evm_tl_leds_device = {: [7 a" ^( z8 J0 e
.name = "leds-gpio",
. V7 ~- a5 w% E) o0 B6 t .id = 1,
* X9 j' d$ _0 X6 o .dev = {
1 U/ O0 R/ b2 ]7 l .platform_data = &da850_evm_tl_leds_pdata,
' t$ j$ v! K0 l) ` .release = led_dev_release,
2 Q. R+ j1 K' W }" h3 G% w4 t @8 r
};5 |# f$ u# e* S# ~ Y
5 n1 R9 h- D7 E, Y5 d/ K
static int __init led_platform_init(void)
4 {/ q$ }9 g1 C8 G2 ?/ [( U{
* E3 Y& w2 K+ B5 s7 \9 U. c/ V int ret;( N. I$ ]9 y4 c% Y3 h+ h
#if 0
7 N$ b' w7 s* ?$ v9 } ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);3 R% l- K2 |4 X" h/ N8 m
if (ret)
. Z0 ?+ j9 F0 Y+ a1 k ] pr_warning("da850_evm_tl_leds_init : User LED mux failed :"& F. E; n8 u7 l# _, x+ l
"%d\n", ret);
n7 d1 W9 l- U# N8 w, O#endif
7 R$ ?. H% V4 k' n4 D1 S# H ret = platform_device_register(&da850_evm_tl_leds_device);
; z z T ]) g! g$ O if (ret) }8 \- y4 x& {" E
pr_warning("Could not register som GPIO expander LEDS");
. Y6 [ o$ e$ F; ?9 X/ k( o9 p else- t5 D7 i) @" H1 P; ]
printk(KERN_INFO "LED register sucessful!\n");
\& M# G+ z! Q+ B& W
% F0 I2 z2 k" k" v: Q return ret;% k# t* Y4 v) Y8 h7 P2 P* B
}5 E5 t; m8 {7 h" }; u, f
& J! s! ^. [0 O+ U, a
static void __exit led_platform_exit(void)
4 Z% J7 S; H( j- ?{
( |1 H+ S, N! e4 s* [ platform_device_unregister(&da850_evm_tl_leds_device);
! e7 w4 [5 J$ S, E
4 N2 q3 S: T* s4 z$ e printk(KERN_INFO "LED unregister!\n");( W- P; i2 Q# \" j* X( [
}
, Y- W: J# {( r0 K a5 x7 I- R$ ~- `5 {! _3 E
module_init(led_platform_init);
0 M" L1 x+ ~- \2 @, W2 x5 qmodule_exit(led_platform_exit);- ?/ ?; N# W8 e
' @ q* e, l$ N8 n( b4 a" B1 xMODULE_DESCRIPTION("Led platform driver");
6 D. Z4 s) h: e; v, xMODULE_AUTHOR("Tronlong");2 D6 _: s/ U1 {/ F$ X
MODULE_LICENSE("GPL");4 v: {3 b* U c' t: y
! i# y: a0 C; |& S
|
|