|
|
求大神给下面的程序做注解,请稍详细些,谢谢。+ Z" U7 ?8 v I0 L
#include <linux/init.h>
& {8 |/ U8 D1 Y z#include <linux/module.h>
/ O$ ^# \9 x; ^2 n+ P#include <linux/kernel.h>" C2 _$ \+ H% o* T
#include <linux/types.h>
% ]# a: n) c' F+ o#include <linux/gpio.h>+ J* F! T* T# E% h. W1 s
#include <linux/leds.h>
6 X$ K( ^3 \# P+ x#include <linux/platform_device.h>
, x8 C \4 j: ?9 n. {
: ^; O- e- k; N' ?8 ]. R. M#include <asm/mach-types.h>
% K, z2 |$ G4 \/ ~#include <asm/mach/arch.h>! d/ k8 i3 P5 I# V: a
#include <mach/da8xx.h>
5 P/ [7 n7 ~9 [" X4 {#include <mach/mux.h>; r1 h9 s3 U! j) v6 ~8 o
, l, t& B! Y) v2 y" @4 d# d
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)1 m% m' l4 _7 Z) n
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)" s+ v, B5 G% @: W: a9 o0 V2 a
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1); T. E$ u9 S, C) u
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)0 {3 ?+ d8 ^, Z
$ r& ]! I0 j& i- H
/* assign the tl som board LED-GPIOs*/
$ u$ `$ d s$ [7 _static const short da850_evm_tl_user_led_pins[] = {3 V4 P3 u: k4 w: a* G6 c: G
/* These pins are definition at <mach/mux.h> file */4 W0 d ?4 t$ p: d) L
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,% ^. o9 v A& V- D: \. |
-1+ z; b7 Y( t7 P, k( L L
};% D! ]! d) v: f7 K8 M) n; {
+ M$ l" L+ X! v5 O
static struct gpio_led da850_evm_tl_leds[] = {
, w& h9 ~# x( Y0 k+ D {
# i" j2 a6 ~6 x2 i' |8 h .active_low = 0,$ `+ f3 L6 g" d6 p d1 q+ b; G7 t
.gpio = DA850_USER_LED0,
3 x0 U1 y# V8 k: k) M- A .name = "user_led0",
; t: @4 D( e" E .default_trigger = "default-on",
0 J, ]" e0 k1 h0 K6 Q },4 ^0 Q g; Y0 X9 _ C
{' ~( `1 N( @" e& o e/ b
.active_low = 0,
- g) r% k& `3 h$ p# q1 T .gpio = DA850_USER_LED1,6 l7 b- s/ T+ Z( N' C( |2 C
.name = "user_led1",
: {% h8 Q, Z( c- q7 q .default_trigger = "default-on",
g) H1 R( v, s, b6 g( f) J },* u$ L* L6 i8 ?/ o# z
{5 y1 J0 J3 R( x
.active_low = 0,
7 q( L& M( H6 |. p .gpio = DA850_USER_LED2,
* r2 F3 O4 S# G; O' T9 ~1 m .name = "user_led2",8 n G! p m R# E" F
.default_trigger = "default-on",
+ @; Q; S( x6 G$ a { },
* m+ u9 ^8 i, i) c6 R% h0 Y {. X) m/ U8 L" V8 |+ M5 |
.active_low = 0,/ e9 }/ @3 W2 Y
.gpio = DA850_USER_LED3,) s9 k y( }+ P9 Y
.name = "user_led3",
+ v: g i! c2 W0 R# f .default_trigger = "default-on",
. `/ G9 T- x. ]- m/ q },- P! a" Z. S/ ]/ j$ I, j" p" r
};9 W- h' U+ M8 C
$ S+ J$ P; U: r! f) c' [
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
% z$ [7 R) A( O; k9 t' A .leds = da850_evm_tl_leds,
, e* ~% Y1 |' ]' t3 ^8 {! j .num_leds = ARRAY_SIZE(da850_evm_tl_leds),3 z7 N. U- n% u( p
};
) c) V' X$ ?/ ]# i
( C4 C2 g: U, X* C% ]2 Astatic void led_dev_release(struct device *dev)
8 T' `% i0 F( X( _" Z: w1 _+ |0 t# E{
2 T: W3 E6 Z% z0 ] |5 B};% f5 }6 Z% C' n1 }' O# [4 O) a
! g1 [( Q+ T; g9 _0 W. v! I% A- H7 k
static struct platform_device da850_evm_tl_leds_device = {
+ u* O: s2 v7 V: o5 P7 M9 ` .name = "leds-gpio",6 n T0 }6 a. F! t$ i1 U: y: |
.id = 1,
; J A0 i* t, A: y .dev = {: j, [( a4 s: o! [) B: B
.platform_data = &da850_evm_tl_leds_pdata,6 f3 \, G5 J6 j- C7 o! h# Y
.release = led_dev_release,
k8 |- k3 `7 w& I0 R, e* v7 ^ }( w( {/ P* E% L$ L
};2 x( f5 x2 r$ {2 Y; A- ?
' u# l& V% }: s+ G. ~8 Hstatic int __init led_platform_init(void)
: _+ j/ m* A+ ^; a# i9 y{; X+ ]0 \- L+ W0 D% G3 {9 |$ m
int ret;
2 j4 c. L8 a1 X @% U#if 09 W' C- X' ^9 [) O
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
% e$ W4 w- s5 y if (ret)
- ~6 ~, b( Q* B) A' @( Z pr_warning("da850_evm_tl_leds_init : User LED mux failed :"2 k+ f* o+ W0 d+ g! l. D$ q% y
"%d\n", ret);& T3 A1 s0 o& z+ l- w. j: b2 }
#endif
. N8 k1 W, a/ G ret = platform_device_register(&da850_evm_tl_leds_device);
5 w# C& |+ X' y# C if (ret): ^4 y. U! f3 Z; f
pr_warning("Could not register som GPIO expander LEDS");
# w$ I. v, P2 f! K( d: N. e else2 t, {% e' Y2 c) x2 j0 i9 O
printk(KERN_INFO "LED register sucessful!\n");7 ~, [% @# h* e/ w- \, ?
, `5 l6 b! d1 H0 `: m7 S
return ret;
% G& e& D$ o( Z1 F5 b}
# h2 f1 Z7 f2 _$ X# {/ p
' G0 I, l9 b" i, e& Wstatic void __exit led_platform_exit(void)
9 A6 b# N8 J5 b- J{
9 X7 i' U3 V2 G( F% Z; ?, x L platform_device_unregister(&da850_evm_tl_leds_device);7 I, h8 `: K" u: p( Y: n
- h2 n& p; d6 F6 b
printk(KERN_INFO "LED unregister!\n");
/ B0 U, a; T* {! C" k( q- s( @0 f}6 G+ {4 e5 M7 N8 i5 @
, U0 J9 m/ B8 N! x) J6 f! D5 h
module_init(led_platform_init);
! A# i8 q. Q6 `$ ^module_exit(led_platform_exit);
# D, e; R; q/ H1 Y4 |+ P. v! |1 w
. ^# p' w' g/ |! [4 VMODULE_DESCRIPTION("Led platform driver");
2 }$ Q2 O2 M, O! MMODULE_AUTHOR("Tronlong");
: d! }/ x o: T# v6 aMODULE_LICENSE("GPL");. x6 z" t8 L! _3 n- [
6 o: _6 O: `/ |! x) W
|
|