|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
- T8 {' I. j9 c0 j {' }- j @8 Y U#include <linux/init.h>4 z0 ~ P" V, J, f9 y
#include <linux/module.h>
+ a" f3 _1 S2 ]7 z2 O#include <linux/kernel.h>: k+ E, C1 p% v- @: i
#include <linux/types.h>8 y4 o& C; e2 i; h9 R, i/ x" Y
#include <linux/gpio.h>
' f$ H# A+ @ G! h) o0 _7 }#include <linux/leds.h>
8 `& ]! H( T9 h! J& B& x/ L1 m+ L#include <linux/platform_device.h>6 M6 Z& W7 |' @
* A: c' r4 I2 t4 \7 T9 h% ?9 h% p
#include <asm/mach-types.h>
8 z( P8 @# H8 D* B#include <asm/mach/arch.h>
7 i) G, p- a; ]1 x8 F. q9 K8 I#include <mach/da8xx.h>. O4 u: _" E7 `0 I: h
#include <mach/mux.h>. k! L5 \( P) M- T
% M" a# D# Z% m$ e+ A5 c& ^#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
( ]; G: a5 j7 C' v2 n#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)) Z5 v3 J* G s8 m: H: ?
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)" C5 y4 U5 [# L) i2 p; S ]( N
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
2 z3 _& i, W+ C. ~/ e% s$ C6 h
' T c0 b! M0 k/* assign the tl som board LED-GPIOs*/
, p! P( r7 J3 G, J7 I! gstatic const short da850_evm_tl_user_led_pins[] = {
! v, V" _ e0 ?- M( k+ p /* These pins are definition at <mach/mux.h> file */, s- b& l0 u7 H$ Y4 C# s+ r
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
6 V9 [; o B, Y; F$ T9 D; J( l0 `1 W -1- }* a( q. V7 c( J/ _0 T- _; _
};
% D/ G, [0 G7 e& C4 E# M; d4 M; D2 x: a8 _% R
static struct gpio_led da850_evm_tl_leds[] = {
" V, w# P8 S. f( |' N m+ E {
7 j' }, Q, q; ~- B y7 a .active_low = 0,
0 c1 H) f* I F; b* j .gpio = DA850_USER_LED0,
. |3 {$ U! C' J# ?2 f9 J* D+ T3 y0 \1 J .name = "user_led0", ~/ B+ S; R) L, q7 y! \
.default_trigger = "default-on",- ^6 n( C: g0 e: V- f
},9 R. g4 I% `/ E' V/ A2 v6 \+ R# n
{
9 u' h- A4 Y1 r4 g .active_low = 0," b& N* v1 H, ^/ Q8 b
.gpio = DA850_USER_LED1,) u$ C1 Z! o% y
.name = "user_led1",
. } S' [5 D9 S- Z/ ?3 K7 w .default_trigger = "default-on",& u1 a* q' P5 c+ E% ]
},: t; q! Z' f# V7 [ I. P
{
( H, W/ t. O8 O .active_low = 0,
. ~; _7 Y6 p+ T* |; g* C) l6 h .gpio = DA850_USER_LED2,8 Y% E0 l$ C5 i$ ^! F7 Y5 H$ w
.name = "user_led2",
# `/ `4 l) t4 N% g9 j0 D# Y2 e .default_trigger = "default-on",1 n Q! O, Y% Z$ @9 \8 p7 B c2 t3 a
},
/ y" m# M: g" K3 _% V" n' ? {3 B, X+ ]8 U" z' H+ N: K" o" d
.active_low = 0,* R: _& y( Y& Z4 h" V
.gpio = DA850_USER_LED3,
# Q1 |3 W" S( a* u# o# f1 x .name = "user_led3",# B2 m' E% L1 \8 Y! V6 b [
.default_trigger = "default-on",
; e' q( _3 g, y! E7 c/ I },
( t( `3 B9 _: R) F4 Q/ O2 R};
9 P3 a' W) p- ^$ Z' z: n: ]/ g. y* C: ~
7 y x2 X3 q' p: F4 j1 z- j* Q! Jstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
* p2 ]" K" w2 {$ }& }: J! l .leds = da850_evm_tl_leds, t8 F, p4 _+ p
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
+ G5 e+ D9 i3 G) ^% b- y1 [};
$ @2 C! r, D* q/ H- a% q+ Z
( W6 @; s) D3 V! g9 pstatic void led_dev_release(struct device *dev) N+ r, s7 z7 v# K0 X2 p
{# }3 x' l2 L. P
};
0 y# _; \% `* A9 Z; v* s$ e4 i, h) \" b, Z
static struct platform_device da850_evm_tl_leds_device = {
C& B" q2 u8 d7 g& q- h( W .name = "leds-gpio",
0 Z; s+ B5 N+ y; P- l& j. \ .id = 1,; J& A; T, @. \$ g
.dev = {0 g n! j1 q. k2 x* O! k3 Y- V! m) L
.platform_data = &da850_evm_tl_leds_pdata,
. o7 c$ m; z4 W# E, l6 x .release = led_dev_release,
& Y* }" |8 W( }3 i }) A, R, W! K8 I
};
2 a) e$ \) i" E, N/ E6 K. y; f& }/ x, s# P9 |9 w/ ^4 ~& @3 K
static int __init led_platform_init(void)) W) R B& ~3 B8 e0 d; W8 u3 |
{
9 I# W& r& X/ o) B int ret;
2 ~7 U+ y( g+ { i#if 0& h# m( u X5 I& H, n
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);" X+ _7 {5 U" l+ M+ ~6 O( v0 r
if (ret)
1 w$ E( I B/ f" k) ^* W% ?% ? pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
$ `3 k- F) s$ N9 s$ s "%d\n", ret);
- K' ~& ^# r0 b4 c4 T3 n1 F$ K. m#endif
E0 f2 o, b6 ]" D, ^0 E Z ret = platform_device_register(&da850_evm_tl_leds_device);
! w. b2 A! q! s: P6 v8 u& U) _ if (ret)6 k, s- |9 u) P! W7 o" z
pr_warning("Could not register som GPIO expander LEDS");
- y! |) k' M5 P else
# o1 ^ g2 }& v# G/ {. ~' Y0 h printk(KERN_INFO "LED register sucessful!\n");, y% @0 k: K# L' z" N- C3 `
i1 M6 g |; r; x1 F return ret; d+ U& E2 B/ h# a$ F
}0 q' ?+ O( \0 H# }
0 }. t# `+ z2 N- Astatic void __exit led_platform_exit(void)' i% Y% K' g9 O& e0 `' }; D0 Q
{% j1 G5 R: ?' I8 ~2 p7 J1 {/ x
platform_device_unregister(&da850_evm_tl_leds_device);
5 N8 M, o) x6 W6 ~' W. b
( A4 f$ n, v$ O$ m& l8 g printk(KERN_INFO "LED unregister!\n");
2 [8 D9 v3 Z# b( \* `% H}3 {* l; ^0 K0 l5 ]( |
( R0 X# G" n) \+ s# |
module_init(led_platform_init);
. Q: ^4 |% h; i& v$ Lmodule_exit(led_platform_exit);
! P* O7 A+ V2 F8 X/ Z, ^0 k8 a! ^* `$ T$ X
MODULE_DESCRIPTION("Led platform driver");0 A3 {$ ?$ f4 t$ w
MODULE_AUTHOR("Tronlong");
6 _7 p! j P/ `3 ?" a9 dMODULE_LICENSE("GPL");
1 S3 N. S6 F5 q( E( O0 U) R
& K9 @+ V# x( A4 f. U0 J2 \ |
|