|
|
求大神给下面的程序做注解,请稍详细些,谢谢。8 f& n5 q) P) a/ L/ u
#include <linux/init.h>
% `2 y1 W1 H7 G& D; o( i. B! \#include <linux/module.h>* j3 W# y4 c+ Y
#include <linux/kernel.h>
: ]6 l. ~' f4 Q: [#include <linux/types.h>9 J% h: t% R/ ?, P) ]# V( F4 N
#include <linux/gpio.h>
+ Z5 R1 F1 N/ B/ n#include <linux/leds.h>
/ A3 z2 x/ i, X# i0 l% ~#include <linux/platform_device.h>, X! j" z/ f# ^% L( B- h' v
9 B, q9 K$ h0 B) X6 U" t5 T; i#include <asm/mach-types.h>
+ D0 C5 B: Q2 N% Q+ ~% _#include <asm/mach/arch.h>" g& b; ?# V+ a
#include <mach/da8xx.h>
8 u: q. R) r' ` i; x#include <mach/mux.h>! Q- q) A" Z. `
* f+ s& \4 j) x+ I; Y#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
. C) V, a' v k0 P/ h#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)0 b. Q' g" g! C% |1 j. c0 l
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
; `% d/ N0 @& l9 y: L1 Z) ]- a#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
$ o; C# W6 z8 h8 w, t( {1 e
- ~7 t7 A" [+ u7 T/ H/* assign the tl som board LED-GPIOs*/" r ^* ~% l( F" W' C2 M
static const short da850_evm_tl_user_led_pins[] = {3 g" d3 ^* }4 |# L# R, K; M" [
/* These pins are definition at <mach/mux.h> file */
* f `$ {# `+ k( \ DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
3 M1 k6 _. T0 [ ~4 T, M3 O+ t -1
( r9 u I, `; g' O3 q5 n9 r};, n+ c) v9 {% j- F
! }- g) a0 I& Z8 z7 @6 `
static struct gpio_led da850_evm_tl_leds[] = {4 E. U1 w- C+ i( I
{! v4 w3 f, H3 X
.active_low = 0,
9 `0 ?/ w8 m, i4 t$ l |; @4 j .gpio = DA850_USER_LED0,1 u) F, s4 C3 U! R
.name = "user_led0",
4 R% `7 B+ r }! q) A .default_trigger = "default-on",* V( x' l$ {0 C8 _" r9 \
},
. {( K1 t* U) M& ?, u: g {
, \2 g( k0 Y+ t( V% \ .active_low = 0,7 a8 x7 g( ?! i+ n% J M* R; ?
.gpio = DA850_USER_LED1,
5 \, m2 \8 f% D/ i$ ^/ v .name = "user_led1",8 @( x4 B* c% _
.default_trigger = "default-on",+ p; \! {: Y% X4 O% Q9 G/ x( g# J! Q
},) L2 f5 \ d2 d; I, W" e
{
8 ~# p+ V0 D' o+ z) ] .active_low = 0,7 [; M5 m% w' ], U* ]* i7 s
.gpio = DA850_USER_LED2,
$ z; Z7 x$ }* m .name = "user_led2",9 p& q5 L4 P' Z F! G
.default_trigger = "default-on",9 N2 n5 a; q }& R% N- _1 X. `
},
) P8 {8 V1 }+ a+ F {7 |. h7 Z# } F) x% C
.active_low = 0,
( H6 F0 N2 \0 `' A, S .gpio = DA850_USER_LED3,
^, _3 L' W3 | .name = "user_led3",
* U0 k& ?; z+ Z! A+ j' j0 y. ^ .default_trigger = "default-on",, p% d; @) k' D& A7 u) f- G* ]
},
h4 l4 f% j& H; V};/ |$ G0 ^ x# q9 K
9 Q) W8 I* o+ u6 `+ N( C* Gstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
$ b& V3 o6 l& ~$ J- M7 q4 g .leds = da850_evm_tl_leds,5 J2 _3 X% U, {2 u7 S1 s7 X% Z5 Y
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
/ `% e5 k- e* m9 @2 ~8 X};
& \7 _% {3 z! e: h4 a9 n: A& j3 Z4 A% M9 G6 E: g
static void led_dev_release(struct device *dev)
* W* x- h4 d' z J' \' _6 ?6 F n{+ m( {& \/ D0 I. A0 ]- c# i
};
! A4 D! C7 ]5 a- W. B+ ~) B0 A/ k+ \8 L+ R; n6 r# Q8 A
static struct platform_device da850_evm_tl_leds_device = {
, f: c0 ]; q) |5 T. l0 M& ^, {: B .name = "leds-gpio",
( K0 K, b% X Q6 m4 X7 [$ ?4 J .id = 1,
x/ W7 w1 s' @9 v .dev = {
: F+ \1 [) T/ o# M .platform_data = &da850_evm_tl_leds_pdata,+ D0 e1 y( m! z. \
.release = led_dev_release,7 S1 \& m) w! j9 n5 `
} l$ j+ y$ ]4 s( y
};
& Q7 x, N. M' U2 I0 F4 C# g) J3 F* X, J( j8 m" S9 Q' X
static int __init led_platform_init(void)4 j" @1 c: ^2 L" M9 C9 y0 _
{
5 j6 g+ ^. W$ B int ret;$ x z" E( c# x3 T
#if 0
Z: F" m' V4 o# O$ K' e. b ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
; X2 S; W# t E if (ret)7 W2 \( k' b7 {9 j
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"1 b, i. W# y: K) w1 P
"%d\n", ret);
0 e4 w8 N8 I: Z1 \9 c2 F9 e! m#endif" ]& M' k6 g. G, N$ V( b
ret = platform_device_register(&da850_evm_tl_leds_device);% w8 c9 R3 w7 I/ t: r9 T
if (ret)
8 w0 U& q7 ~9 l pr_warning("Could not register som GPIO expander LEDS");
3 J7 C! y; J7 p: B else
3 ~$ r) D! X* u& ^( D printk(KERN_INFO "LED register sucessful!\n");8 J3 D+ t$ X0 C% M/ H# D
7 R- ~; j- @. M7 q return ret;9 ~. [0 N2 X, t( b- d# g! _0 [
}4 R, m* x0 e7 G; T9 H( [9 M. J
3 H: S% d$ [ o9 E; X
static void __exit led_platform_exit(void), m& Z4 B/ M6 c3 {
{
" D. f* e6 k0 ^6 K platform_device_unregister(&da850_evm_tl_leds_device);
! G" k+ l& K0 O4 e# L% W
) j4 o# z" O6 E( l" d printk(KERN_INFO "LED unregister!\n");
3 j* h; R: B4 y! l2 X}; q4 T8 O8 q5 k6 ^7 N
9 `' C; q; Z7 e+ j- V
module_init(led_platform_init);
* f9 ]. A) q, R9 G @/ xmodule_exit(led_platform_exit);
4 ^3 u: c |+ ]7 J5 k- }
~& \% e# c7 Q7 ~MODULE_DESCRIPTION("Led platform driver");
( Z$ i1 f, x( r1 b# ~1 AMODULE_AUTHOR("Tronlong");
* W3 F. t( M& @4 d( [1 g# ?0 pMODULE_LICENSE("GPL");
1 s3 i. t/ p2 T9 x9 C% V9 P, W
# \$ M3 D @. w |
|