|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
7 s3 B' b9 S: r0 v3 g( t#include <linux/init.h>
- Q' c& K3 q8 R2 g#include <linux/module.h>4 s/ H/ N- b% H- ~! {
#include <linux/kernel.h>
T( {* l. l9 H+ \ Q$ A#include <linux/types.h>
+ W/ [! O* _) R+ J#include <linux/gpio.h>
, \( [, M9 y/ C, r2 G& i/ A% h#include <linux/leds.h>! l9 h3 b3 Y" @: ] K
#include <linux/platform_device.h>7 d$ K8 \. k3 H6 m+ S) `7 A
% | H6 l1 j1 T( W#include <asm/mach-types.h>, p3 T& C3 N2 Z/ R' R4 D+ w, o
#include <asm/mach/arch.h>5 l1 L! u4 X4 i& }* @+ q/ R
#include <mach/da8xx.h>% a; X5 g- b* _/ t$ `- r
#include <mach/mux.h>
) [( N% n5 D4 w- Q1 Y. r7 t8 i0 j" x& E
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
1 B3 R& c+ W$ m' d! |5 |#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)% M$ M! ~7 K$ q8 I) w9 W& b
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
9 \ n' o+ ]3 U7 t& g* o1 c#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)( O" ~! J+ v3 @: |
6 K6 G, }: R* A. B) @; C
/* assign the tl som board LED-GPIOs*/( ~4 [1 p: {3 S
static const short da850_evm_tl_user_led_pins[] = {2 R8 u3 N0 [/ V4 G8 D3 ^5 a- v
/* These pins are definition at <mach/mux.h> file */. R0 g1 n; s/ Q1 `3 A
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
, y; T4 I3 b( }) G$ T -1
; B( c; Q3 {3 B% o+ r- o};
, p! C0 ?5 f1 {: U* U4 X0 ^7 X5 e9 S6 r3 |7 D7 Y: c0 o
static struct gpio_led da850_evm_tl_leds[] = {; a# D$ V+ V$ N. k8 [6 q: l5 |7 U
{
% B6 v$ i3 y/ } .active_low = 0,
8 Z( _# i! t# R .gpio = DA850_USER_LED0,6 Y: Q. k% }! n
.name = "user_led0"," N% }8 b7 ^- Z" o1 u+ V" k4 B8 g
.default_trigger = "default-on",6 d- J) X) P, @2 A
},
8 m( Q4 c9 s+ z; r {
( j/ }; v1 y6 U6 \0 E .active_low = 0,
7 u1 T+ }1 S5 X* h4 T+ j2 P# Y& } .gpio = DA850_USER_LED1,: k! a5 A- W# a! @' F& r
.name = "user_led1",1 W6 ]" m& L- ~6 D8 R0 |
.default_trigger = "default-on", K- a4 ^: h) s% x1 ]
},
4 S: u1 o# a9 e0 }0 E# O {* b( Z5 \: J. q, r$ _; |8 p( |% m( h# j
.active_low = 0, S2 E" Z! g: s1 K: i
.gpio = DA850_USER_LED2,- q2 @1 F1 ]" C8 b( ?" v. J
.name = "user_led2",
3 k; S- \/ b4 ~( k/ k+ y4 b# e) K4 N .default_trigger = "default-on",; H/ S+ l, W, c
},2 r R( B( t. z) Z7 Z9 T% l
{
! y( H! M x, n V/ }1 \ .active_low = 0,& B% x# [3 t% J6 x$ w8 f
.gpio = DA850_USER_LED3,
* ]* ]* d2 J- r4 y3 x .name = "user_led3",# v& S" v9 m* H5 o2 r- l
.default_trigger = "default-on",
& Z- B* y" L" U8 P- @% Q) u# A },
# P$ [, Y! T4 \( f, l) ]};
$ {1 m3 R% W& V# g, m
+ c" Y8 M- M/ e* cstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
7 F& O2 t' y2 c+ w: @ .leds = da850_evm_tl_leds,
+ V1 h6 r/ L; a- w9 M4 [% b .num_leds = ARRAY_SIZE(da850_evm_tl_leds),: O x7 E0 b' U q& b: [1 u1 H+ P
};
4 d0 p; w( Z1 Y. i: R/ q& I. Q9 B
static void led_dev_release(struct device *dev)
6 M8 A0 M& w3 N2 f{" v7 U7 M: j) r. F2 f, n8 v5 \
};
5 d/ [% M3 W7 `
* n. O) ~' T4 c- ]3 Xstatic struct platform_device da850_evm_tl_leds_device = {
% [9 u3 ~8 M' @( g .name = "leds-gpio",4 a# Z0 g9 B6 j1 `7 h% ]
.id = 1,. K/ U$ a5 H ]/ |) c! ]
.dev = {! A2 y, ]3 |& q3 _4 {/ C
.platform_data = &da850_evm_tl_leds_pdata,
; k/ S6 u: d6 v; d4 C .release = led_dev_release,( z& u# E! J9 M J8 Q
}) Y& N6 L: a) S% e3 K! N* }
};
1 ?7 H$ h. X4 l. b! x3 M# H9 G
8 W ?& I- T# cstatic int __init led_platform_init(void)5 h) m& f+ f: `8 G& v
{
: C1 E7 J8 C! r int ret;
7 z* H% t0 F5 _* ?, v9 N" L5 I#if 03 o ]. U+ T% n7 j6 d2 a* V3 d, A: i
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);: W) R( z: ~7 S9 a; E o
if (ret)
0 q9 j7 x& a& {, g+ }( q" [: ^ pr_warning("da850_evm_tl_leds_init : User LED mux failed :"3 e1 @1 _7 D1 m4 C) Q
"%d\n", ret);% y) j+ |! Z/ {4 Z; U b
#endif
! Q+ g6 ^7 `1 Z6 Q" Z ret = platform_device_register(&da850_evm_tl_leds_device);2 s. ^: R5 {5 h% L" @
if (ret)* i$ q5 g% L- z8 ]
pr_warning("Could not register som GPIO expander LEDS");5 M1 g% {4 {2 o/ \5 Y: Y- F
else
1 U5 J" D- M( c) D3 C5 m/ |! E5 A# F- x printk(KERN_INFO "LED register sucessful!\n");
7 O- s$ c2 f* ]
2 I, H# p2 W4 x w" z' A return ret;) q @: h* G4 [: F2 b
}' w5 d9 `! S6 T' l6 F
0 g* C. W, h, X6 M8 l9 a, d5 |static void __exit led_platform_exit(void)
2 y) ?' o( R# N& n{
( k+ A3 d" o5 `3 e platform_device_unregister(&da850_evm_tl_leds_device);
2 p8 q. |' E/ C3 Y& L- e
6 k; N, l! |' w$ w printk(KERN_INFO "LED unregister!\n");/ t+ b, }7 q) x! v2 l
}( y+ y6 E+ ?( I( b
. U" g" O X2 Imodule_init(led_platform_init);" j& v; c) k( X$ Z. ]2 l6 y2 y
module_exit(led_platform_exit);
: J! b! H% @- D6 F" d, r, y W
& q. K: d6 f- q0 ~ E+ oMODULE_DESCRIPTION("Led platform driver");0 ` @" [# Y) _
MODULE_AUTHOR("Tronlong");
+ ^& j1 \3 d$ \' [* A& ~MODULE_LICENSE("GPL");
+ U1 d( }2 c8 X2 {/ O- J+ r! i/ D$ p: a, P4 q6 B
|
|