|
|
求大神给下面的程序做注解,请稍详细些,谢谢。6 W# `/ V( C# i
#include <linux/init.h>* e, F! ~: X) R G- L7 q; H
#include <linux/module.h>
8 V p& Z+ e8 N: s4 a#include <linux/kernel.h>
6 i0 X! ^8 M' e# I2 h#include <linux/types.h>
9 {8 h1 H o( n9 S$ G4 h#include <linux/gpio.h>
- c9 ^3 o7 u$ ]) B5 _" f/ F6 G#include <linux/leds.h>1 i+ E, Y0 {0 Q7 U$ k* a
#include <linux/platform_device.h>) m, {, `5 O( P" O
3 }( U* r7 j7 `9 `1 c1 c#include <asm/mach-types.h>
) z4 L) s, U( I+ `#include <asm/mach/arch.h>
/ ]' U" V' B% {* {! v4 U#include <mach/da8xx.h>
, T4 R' X( y6 d#include <mach/mux.h>8 _) _' Q4 |; }, ~
: ?1 z7 h1 _! ?* a! q! _6 _8 C
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
- T/ `* J3 E; A2 L( W4 G#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
. i# r5 j4 B4 I. f#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
! r; q6 r) {/ d& }- J* n#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)3 I* M4 x# ]7 J g8 h3 d, E0 Y& n9 }
; @/ U1 M% y! i
/* assign the tl som board LED-GPIOs*/
& A% |3 ], i# N3 o( Z J7 y/ Hstatic const short da850_evm_tl_user_led_pins[] = {
2 s% s; a* n4 k" K3 t, K /* These pins are definition at <mach/mux.h> file */
z, K7 J$ z" c6 f2 F DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
- U1 ]$ T: J H -1% i8 r0 o! z/ X5 R5 E+ O4 E9 K
};
1 L5 \1 f; e; c/ I6 x4 X, N; V# H# x. a' B6 b
static struct gpio_led da850_evm_tl_leds[] = {- E2 Q- Z( y) A. x
{
d& j- z" N, h# y4 t8 E- A .active_low = 0,
5 D5 [, l0 H& P5 W3 z5 w0 `' j .gpio = DA850_USER_LED0,5 C% K, J$ ]$ v
.name = "user_led0",
7 M) a8 \. j- _7 f. Z W .default_trigger = "default-on",9 U5 T0 {; { E3 j% H( `
},* x1 y; h* X0 T9 N) J2 n$ g
{
7 u, S0 t- _. h& i7 F .active_low = 0,' j7 }( G, H& N8 x/ f, T+ |' U6 L
.gpio = DA850_USER_LED1,
; `% _7 F* f9 l+ x9 Z .name = "user_led1",& z# T) |3 C! H- R# S
.default_trigger = "default-on",
$ L1 \# U* \- v6 \8 O1 L },% m5 `, |( O/ U$ s8 A7 J2 K' S( `
{# X% K: ^: Z0 d1 y: \; N
.active_low = 0,1 b1 Z2 H& ?( J$ c \5 W! E) L4 m
.gpio = DA850_USER_LED2,
. |6 |& T2 D# g5 X' s( U .name = "user_led2",1 q& K Y2 q& T' C# Q4 [5 x' R4 C7 N2 ]
.default_trigger = "default-on",% | i# d A9 z- ^& O& ^( d* O/ s
},
" e3 `$ i3 T* j( g' g% D+ u( } {
6 n: Q1 N% k4 l6 [' T+ O. W- n .active_low = 0,
~% q" X+ ?0 H* R) Y .gpio = DA850_USER_LED3,2 |( K) D# Q* X. t9 F1 J
.name = "user_led3"," n5 u5 D9 h1 K4 X
.default_trigger = "default-on",
6 v N( e* d! D( l$ x) u/ I },
G- w7 q2 e+ C};
' G. m9 U: c' X
* }* o/ m) a E5 n& F) o2 h3 ^static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {/ J3 J9 c. \1 B( ?* n$ l5 r. F
.leds = da850_evm_tl_leds,' c6 h' T: n( F3 Z) A0 {5 z
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
& b6 e C$ v/ W( i};
6 c6 x/ w& Y' _2 \6 o2 `' f1 \5 N% C4 z+ t i( _
static void led_dev_release(struct device *dev)
! s3 q, p8 F. c4 U{
) Z9 U' G9 y. g/ L};
# V# L# T8 ], ?
9 W# w; T. q5 D+ C; Sstatic struct platform_device da850_evm_tl_leds_device = {
" R7 X: N1 W# y' R/ K .name = "leds-gpio",
$ E9 v7 n3 Q) {: h! t' v6 W4 T! z .id = 1,4 g* d1 f2 _/ L' F, L) n
.dev = {
; z& ^, X4 I" G* {) u+ P3 h .platform_data = &da850_evm_tl_leds_pdata,
" c8 F& b% A, i8 s- R+ h+ d% |5 r. w .release = led_dev_release,
1 w4 V1 T) \5 E l) [ }
( i& W* w3 m9 V/ N6 X# s};* H2 w( e$ x: H* a5 P
4 x& n! r4 P3 `* P
static int __init led_platform_init(void)) l- X0 W2 W# K( O) [: a* o3 A
{- I- s% M* h% t' V+ P8 S
int ret;4 W9 A$ n0 |# t/ i/ ^3 m
#if 0
' a0 j8 d; b* p0 F2 s: I) a& o ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
* Z/ D. n! l" a0 E( ^6 Z if (ret)
2 P& b5 S7 X, l, K* @8 G5 T8 e pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
" [4 y6 \, h# _" M. v "%d\n", ret);
1 I# l @8 y5 P" ^#endif4 \9 d" C( X. W# W3 q1 Q
ret = platform_device_register(&da850_evm_tl_leds_device);. B% ^3 X; u' e/ `5 A
if (ret)1 W2 L" V# ]! Y- e1 F
pr_warning("Could not register som GPIO expander LEDS");
5 }# y1 `) k$ s! i* s. N2 S else
* U6 Z4 J. L5 O printk(KERN_INFO "LED register sucessful!\n");
: V" Y/ ~& q/ ]6 x# f! X) }- Z# } p
return ret;
- ^5 \1 y0 Z2 z/ M. m1 j" F}
; _9 V4 C6 Z1 H+ p+ E( M2 D( @) l4 @1 t* U/ Z; C
static void __exit led_platform_exit(void)) p2 ^5 \7 Y" B
{
5 _* ?6 W/ D/ g2 S! } C. N platform_device_unregister(&da850_evm_tl_leds_device);
& F k8 W# ^% F e7 K
# E" C! _' ]0 V; m printk(KERN_INFO "LED unregister!\n");
! o0 }0 ]" r: z0 L8 _8 t; e}
8 x/ ]6 A z/ l, r% I3 l2 [' D# x
module_init(led_platform_init);0 ?( o y* D V) }9 S/ ^$ j' J; w# C
module_exit(led_platform_exit);7 T5 h) G% e& q0 z
, G) f9 @7 D! D0 P6 v3 T0 E4 L0 r: E
MODULE_DESCRIPTION("Led platform driver");
5 @( \5 k1 l i5 NMODULE_AUTHOR("Tronlong");
. O1 ?9 w- T+ T" s/ g! pMODULE_LICENSE("GPL");
9 w; W W |" Z/ d+ `4 p9 G/ n
6 ]5 A6 U5 G; ^% i% S o |
|