|
|
求大神给下面的程序做注解,请稍详细些,谢谢。" S' C$ j+ |; r, c1 A; V; B
#include <linux/init.h>
' A* M6 H4 I* m3 n+ f* Z#include <linux/module.h>
+ D. [6 u' o$ f7 A8 T# j#include <linux/kernel.h>5 `2 |2 J. Y5 l
#include <linux/types.h>
" o) T" O* E. U" a. r; f4 l( T& p6 _#include <linux/gpio.h>% c& U6 \. ^( D3 L5 c! u* p
#include <linux/leds.h>
) @6 I: \6 ~1 Q& X#include <linux/platform_device.h>
2 f H7 l: v9 \) P+ u! Q$ ]0 Q* C6 x: ]4 F) U
#include <asm/mach-types.h>" @6 Q" i1 w' W- b& T' L
#include <asm/mach/arch.h>; a( r+ o D2 y/ }4 H* C
#include <mach/da8xx.h>2 i9 j8 s$ T2 ^( O
#include <mach/mux.h>
# m5 W' k/ s/ M! x; S) Y/ S+ J0 S6 |! a: \
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
# G; b7 B; M: h7 x; G/ G#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
: p4 |$ M9 k( N& q+ F" r#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
, H! ]1 J; B* C2 Y#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
6 X+ c x+ } [$ m% ^2 t/ J* z2 V6 j' q$ P7 l! b
/* assign the tl som board LED-GPIOs*/
/ {6 @/ v7 x7 b. F* P7 Zstatic const short da850_evm_tl_user_led_pins[] = {
2 _; l: N- W/ b$ u# j8 [7 o) L /* These pins are definition at <mach/mux.h> file */! ]1 `) n- R- r$ l( {
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
: k5 W0 b2 ?" ~/ E7 C$ U -1
) j+ ~ t/ G4 V; r};6 h8 @1 r; H* _" [, D+ F
* o" u9 x. V( _6 w# y6 ?; Rstatic struct gpio_led da850_evm_tl_leds[] = {
2 R" u3 j$ R' }3 z9 ` {
# D! z# ]1 c" f" ~+ [2 w4 }+ k& M .active_low = 0,
6 Y3 @* M7 S* m5 @ .gpio = DA850_USER_LED0,
7 A) y5 Y* _; f T) u .name = "user_led0",
0 S4 I/ {8 y4 ~/ [6 V3 C! U4 w% Q .default_trigger = "default-on",$ D9 a. _; x# w
},4 I2 o0 U1 s" A6 W
{! J9 s, u( Z' Z# @1 }+ G* g, r- a
.active_low = 0,+ i. h5 t$ ~ |
.gpio = DA850_USER_LED1,
* c$ z% J* H3 |: x( \% k) }. f .name = "user_led1",
. Y5 Y8 s1 g. E6 B .default_trigger = "default-on",; a7 C: S' D( l7 a+ P- U
},
" c# ^ ^, C$ J5 V4 q {
; ? F9 x0 k; {8 z .active_low = 0,+ S0 p2 l: H) t0 j
.gpio = DA850_USER_LED2,
: A, k+ [# }9 t/ H6 H* e .name = "user_led2",& j" ]' u p- U: R# L7 M- z
.default_trigger = "default-on",
4 p% q5 {9 C$ a: ]* P },: v8 u1 v* t. H
{
' e( N, e K% t p! o7 l& J .active_low = 0,
3 w; }0 N3 Y) T" M' q .gpio = DA850_USER_LED3,+ t' K& q) ^9 V) l
.name = "user_led3",
6 G8 k/ p8 d ^! s! j# f .default_trigger = "default-on",
9 D' X3 L6 r$ O) G8 E },
' }0 n K- W: ], V- {6 p};+ y5 s0 r, [$ x3 l
. m8 F$ q0 f% f1 r. s# A: K- ustatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {6 x! F0 ~' Q w6 n# F+ C5 h
.leds = da850_evm_tl_leds,; j4 }' a- Z. N8 {8 k2 ]
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
" s5 m. O9 b1 V1 D8 l e1 ]& Q};
- U% @! T3 l' H! b6 Z: y, [: z' |; Z
static void led_dev_release(struct device *dev); A- }2 Y4 k6 t( m; t, }% |1 e
{
7 F* f2 C: Y. G! g% O0 o};
, s" g* K4 e: s( {
5 i* N. U9 m% O' X% r7 Estatic struct platform_device da850_evm_tl_leds_device = {! @; L2 W/ u, A- c
.name = "leds-gpio",+ {+ c$ ?4 I" L1 o0 H$ j
.id = 1,; d2 W9 F/ W2 Q9 R$ L. _; n
.dev = {
+ t8 {) i+ A/ z- o .platform_data = &da850_evm_tl_leds_pdata,5 @* ]& j$ u! n ^8 J4 n8 L- ^
.release = led_dev_release,
3 m$ }* E5 k3 b" j }9 @; U* @$ s( u7 z
};
. A! x# C0 r _$ l8 h- F7 U+ c9 h- L
static int __init led_platform_init(void)% w9 {7 m& v+ w5 a! L0 e4 J
{+ X+ p1 d! l' p5 I8 U5 z
int ret;8 \3 y' S" v: ^
#if 05 z/ M2 s& i: {4 k5 {2 S( z0 o1 L
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);" d, m) h" u) u' k$ q. @
if (ret)7 u% [' F1 x. P) I
pr_warning("da850_evm_tl_leds_init : User LED mux failed :". N8 x$ G- j. X
"%d\n", ret);
: k- w- W; }$ T8 \$ u) N#endif
# s* |! k" f- r0 ?) t& a ret = platform_device_register(&da850_evm_tl_leds_device);4 q4 j2 @. N* K/ S& i$ F3 }) ~
if (ret)) h" M3 l# x% C0 R
pr_warning("Could not register som GPIO expander LEDS");' \) E- a! D% j+ R1 p5 [! {
else: \2 B" ~2 i8 D6 b4 t0 O' S6 ~
printk(KERN_INFO "LED register sucessful!\n");. D- g( v: j) y. t
+ \) q) T9 S7 @8 j5 r( s' j
return ret;
! P8 a* F, r( O8 w P}
+ Q2 _$ [" H ]# l% ]% N
3 a0 ?9 o4 I+ [6 @! b" F4 w1 o! W9 y. hstatic void __exit led_platform_exit(void)' c3 t- D6 k- f9 h: x
{
+ `: p k X( A( u) {- n platform_device_unregister(&da850_evm_tl_leds_device);' w0 n9 V, S2 I/ [4 z
5 K' b. F& v% ]) z: v. W; z
printk(KERN_INFO "LED unregister!\n");
( a; F7 k3 S% N4 h& }3 Q}
& R( h5 o X6 S. g( Z2 ~/ \. T- \) l% }, A; A( z
module_init(led_platform_init);
7 X) {, Y( _( K4 V9 Q7 p8 G8 [module_exit(led_platform_exit);
, F" ~5 W8 a( Q8 V- |" d2 H- q- |6 S( L: E: G0 ^# T' \
MODULE_DESCRIPTION("Led platform driver");
/ |1 {( R- {6 n. i% |7 P6 I. }4 KMODULE_AUTHOR("Tronlong");" \+ |* Z/ W9 [9 U" }& N
MODULE_LICENSE("GPL");
2 a# [& v: y' l' b v' j5 A2 p9 N8 n" k6 y0 ~" \
|
|