|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
+ H; q) R9 G$ J#include <linux/init.h>
4 Q, w3 g% H& L$ K/ |#include <linux/module.h>' k7 o: P; d9 e8 A% y0 y4 l# \
#include <linux/kernel.h>
/ u) V" I2 Z- z8 |1 Y2 W w% U#include <linux/types.h>
, y; ]7 o" x6 J#include <linux/gpio.h>
+ w& w5 L; j/ _4 [! @2 N4 f. m* c#include <linux/leds.h>
* I- a0 C1 d, B& l1 C#include <linux/platform_device.h> Y5 Q2 p2 H, e
+ o# u. `( o4 |5 O6 i. h% O( O
#include <asm/mach-types.h>
6 W- q+ V% `0 k#include <asm/mach/arch.h>, D- r8 _ t/ d9 K' ?5 U* J
#include <mach/da8xx.h>% |5 H) t% t+ x& m
#include <mach/mux.h>
3 E0 w& t4 F9 b& N# T6 Q8 G! o8 S
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0); B c+ l5 s) z, {. ?
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)" i5 s3 O7 G _! ?& e7 W. x* d
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)2 N- L1 G# C" Z/ p$ B
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)* k6 F& |" z/ o. `
& Q+ Y8 L8 I3 n$ {7 ~) z
/* assign the tl som board LED-GPIOs*/
& H: l8 d- s7 ]3 p' n4 [6 d$ r# Astatic const short da850_evm_tl_user_led_pins[] = {
# p( N; m' t2 v3 S5 n- J" A /* These pins are definition at <mach/mux.h> file */
3 f( T7 U2 R3 i9 Z! o* A DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5, M q1 A$ ~; h8 t
-1# o! |( R3 h0 a8 y& r" K
};
) v0 [- T; O+ C8 n: e/ B1 Z
! a: V" V- ]+ b+ M# mstatic struct gpio_led da850_evm_tl_leds[] = {/ k8 a5 g- b+ i- m* v; E- v
{5 g6 V p8 T/ W
.active_low = 0,
$ N! L/ \9 g7 ]" L' Q, Z .gpio = DA850_USER_LED0,
5 e' K9 ^6 ?% } .name = "user_led0",
! U- z2 [( ]/ J4 r1 ~1 j( Q. { .default_trigger = "default-on",. T5 W) Y3 Y$ o7 d
},5 W. T8 R- O6 h7 y: v8 B" c1 Q
{% _( z8 }% u- ?
.active_low = 0,
' J, [2 S0 `* f5 l0 @3 u .gpio = DA850_USER_LED1,
1 T) I) o$ I4 g .name = "user_led1",
; k. W* a0 O& q Y$ R .default_trigger = "default-on",) k: E" {6 W3 L* I I2 n! M6 W& U
},, m: V) F. w' G, c, I; _, M
{1 b1 B1 _% r& {& s: @. R2 x
.active_low = 0,
@" o8 _: k* A" I+ G( W .gpio = DA850_USER_LED2,
( d/ u5 R' `6 E8 o3 X1 m- | .name = "user_led2",
4 X9 `" C1 s2 a+ ]- v u2 [ .default_trigger = "default-on",
5 Q0 Z" [" r4 U& }% q d* W },2 q9 ~1 Q; N6 e( E
{$ h. z) Y; ~+ W' Z$ j
.active_low = 0,
{' X+ g2 K k .gpio = DA850_USER_LED3," L, D. Q1 V2 V
.name = "user_led3",+ p1 _, m- D" L1 p8 G7 y0 ~
.default_trigger = "default-on",
, _1 D* k8 D' K3 \ |; M; r }," {' L0 H3 Y% {
};9 ]4 K1 Z5 T" N- B
0 A$ F) g. e2 i
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
1 L$ K! D& E0 O$ a .leds = da850_evm_tl_leds,
$ [/ {! Q2 |/ v5 A" S# Z .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
2 k# r3 x2 Z; A3 P5 }' |1 y$ P; S};
, o# d' D) b1 _( S9 l" f2 H7 _$ K% D, K& R- Q# `: t- q. M4 c* }
static void led_dev_release(struct device *dev)
( T0 y T1 s8 E. F. \) P# T3 E{
/ D$ A ] ^/ i, J9 y};3 R- N$ p3 \/ T8 _) }" }
4 ?+ n$ O1 k0 L$ I
static struct platform_device da850_evm_tl_leds_device = {2 B7 c5 p9 W- p, {: [
.name = "leds-gpio",
8 n, ^9 x; V1 W* T5 b6 x4 w+ ~ .id = 1, [/ B/ y8 _) s0 f' \1 o
.dev = {8 |/ K5 O4 B1 L, ^
.platform_data = &da850_evm_tl_leds_pdata,
6 m& r% ~6 B2 o3 A+ P .release = led_dev_release,
3 [, q5 c1 _$ R5 f+ r }7 p7 _) T1 ]" R/ y) q3 b
};
; o# d" U% }( M4 d. |% j8 a2 N3 ?$ E% E
static int __init led_platform_init(void)
7 J1 c8 K! p9 @, G3 r{
: z4 v+ }2 c/ h int ret;
+ e; h( `6 f9 |4 g' ?, e0 W#if 0
4 I) I: [ S3 Q1 b" z' o. F1 r7 e ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);: [- Y$ Q8 }8 S8 M
if (ret). q! J7 ]$ b7 K2 C+ q/ X
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"" n/ G6 K* _4 Z% r! R9 O2 P) a
"%d\n", ret);
: d# m8 h0 s a, b/ i% w$ e#endif2 ?& ~- t7 B ?, J
ret = platform_device_register(&da850_evm_tl_leds_device);
/ F3 N. b% {& O if (ret)' q+ E* ]! d& S+ \/ J) @
pr_warning("Could not register som GPIO expander LEDS");
& F) S" n, v: T2 ~ else
! \& W/ D4 N% [ printk(KERN_INFO "LED register sucessful!\n");2 c% ^6 v$ w( A) G& Y1 Z
6 z5 E* X' S; ]9 ` return ret;
2 Z- @- Z2 `2 J1 A: Y7 ]}
1 {$ [( I; R C: G. A' P1 h9 k$ `
9 m3 J( J$ B) b& r! jstatic void __exit led_platform_exit(void)0 `' i- J- ~8 W0 A. { S
{
) M# y( }6 d# g6 I" F% ~ platform_device_unregister(&da850_evm_tl_leds_device);
! U9 y- Z7 Y. Y2 J( F: g, F4 J" ~2 l, Q% M, j9 w" K
printk(KERN_INFO "LED unregister!\n");9 K( O2 F4 g, U* a5 n
}* e/ o; e' M% P" y* a0 c, ]0 c
+ W; S& l x" |module_init(led_platform_init);
7 v; y: k. H0 ?+ Q# m5 E" i3 u; xmodule_exit(led_platform_exit);* Y+ w9 b, x* F# w' D
7 O: ?& s7 P b# s8 C. p4 V
MODULE_DESCRIPTION("Led platform driver");9 q9 X7 X$ K6 {! G/ |
MODULE_AUTHOR("Tronlong");* i, a5 r3 x( ^8 f9 q1 |! }6 W
MODULE_LICENSE("GPL");
. |$ f. ~ [- H1 R- E' v
! v: h) f! f+ Z& _; C1 _ |
|