|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
. `2 @( A- L$ e. z) O#include <linux/init.h>6 P$ U8 `- s( E0 n6 T/ q, g
#include <linux/module.h>* {% ]) P; J+ r2 ~
#include <linux/kernel.h>4 W9 r2 d }: x, f# y' s- m# a
#include <linux/types.h>. [8 T- i' B2 x
#include <linux/gpio.h>5 C( [$ l# V" i$ j" |- T
#include <linux/leds.h>/ Z0 {5 q0 J5 Y6 W/ E
#include <linux/platform_device.h>- w# C$ W4 }" M% y; x
9 C6 b3 C# M4 l4 N. u0 M#include <asm/mach-types.h>' Z1 N- K2 B0 m+ C/ r o8 A# |
#include <asm/mach/arch.h>) O) x( |) X3 k7 P. V& a( P
#include <mach/da8xx.h>' w. h2 A* `$ x9 }& J
#include <mach/mux.h>
/ s1 H7 p7 V, H. @2 D' Y7 E/ r3 p) M
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)7 [. e: }6 l) I( a2 q! F! w
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
$ ?' X( J$ ]- s#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)' M* {8 A L1 p" B( {! Z
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)/ f, P# `$ w2 Z. T; I) N& `
5 s' ]1 y6 x( H8 V8 D) ?# ]: D5 u/* assign the tl som board LED-GPIOs*/
7 m5 h: H/ \% L; ^; x# w0 Sstatic const short da850_evm_tl_user_led_pins[] = {3 e' ]! G' J+ R& G# N- W
/* These pins are definition at <mach/mux.h> file */6 U7 p& j% r" e+ y' v {; O, ?# [
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,3 g. K4 ?5 z6 R
-14 r2 b) u/ i! Z/ P/ b& Q e
};2 Z4 q$ g4 @, q. H y9 J
. m4 n% j% a2 w0 [
static struct gpio_led da850_evm_tl_leds[] = {
( w8 h9 P4 X- Z- Y F) B- ] {/ Z1 w: s2 L2 _: i: o0 c
.active_low = 0,! W& A4 G( J8 U" G/ ?' _6 Y: t2 k
.gpio = DA850_USER_LED0,0 a* s7 `! c& g! ^3 V9 J5 D+ T5 W! ^
.name = "user_led0",, n, u6 m9 C/ j% _- s
.default_trigger = "default-on",
! r" e' e- Y3 C( S },
- ~" \1 F! j) N4 I) e0 X% F6 l {
8 E- ]- t! M5 j' V* T; c& V- {; G .active_low = 0,' J9 y+ L+ f/ m$ G0 v* t1 e
.gpio = DA850_USER_LED1,7 @ Y" @0 O/ V' |' U6 k+ R
.name = "user_led1",
4 B- z: q4 b. |3 }0 N6 ]0 o+ k3 W .default_trigger = "default-on",
% n6 v9 c4 a7 {! s, f1 t },4 P- v ~8 f/ t5 W& ~
{
+ T0 p+ P0 |) ] g .active_low = 0,
) l) g$ H' X- B .gpio = DA850_USER_LED2,
( _1 N6 F1 x0 |0 a .name = "user_led2",1 ^5 y( {9 H# W5 a- o; M2 p! r: C
.default_trigger = "default-on",
2 I/ `% [. b! O, T" U( x( ?$ k9 S# m },4 J& N1 s1 u5 t0 i1 ~
{
+ Q2 f- B# Q- D4 O+ J" w( G5 _) }. Q .active_low = 0,6 A9 c# \- Z- v" Q' S1 b
.gpio = DA850_USER_LED3,
8 T$ A6 _+ K7 Z5 J .name = "user_led3",. h6 O1 v4 l: j; M1 O! T* [" H0 O
.default_trigger = "default-on",
% s! j- ~* T% B( P },( ] g" A" M$ w& h2 P
};
e1 F6 G2 J# q" \: Q2 e/ g. a8 E1 f! S: _
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {$ h6 T' l, e/ \5 @( M
.leds = da850_evm_tl_leds,! l8 d' ]' U; w8 P1 n, c1 D
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),8 d5 c7 P3 @$ z0 @+ q7 S7 s
};
. z/ B7 T( s7 A- B* K$ I( C6 u# V# Y$ g
static void led_dev_release(struct device *dev)9 D# r( W) M8 ]4 c/ X
{% R1 b! T. T6 t) v" ~- x, J: L- n
};
' u& k6 D9 h6 j, U
2 d& @: Q8 @ X; S& o% Nstatic struct platform_device da850_evm_tl_leds_device = {
1 ]6 P$ K0 S6 B .name = "leds-gpio"," }/ F% ], d' J' L, [. P1 r3 P" H
.id = 1,* J) M# S2 J( Q$ }" _
.dev = {
9 D; j+ W+ U; A; i6 n( x .platform_data = &da850_evm_tl_leds_pdata,& l f x; E1 @6 k4 s
.release = led_dev_release,
! N3 |* g7 y2 B5 k% r/ u" G }7 A( d7 G! I; U% |( C" i# {+ x
};0 h2 l9 ^+ x3 i+ { T
4 C* X7 x- e7 \
static int __init led_platform_init(void)
/ R8 q4 w2 L2 o$ u{% a0 V( V" n% \4 S) T
int ret;
! j7 Y- T" ] L8 O# t/ B#if 09 g1 x! x- C5 A- o/ ]
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
! {$ N; T. u0 X5 P4 q, v: ? if (ret)+ @) a. |$ k, z: B; p: r7 f8 E4 `5 Q
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
& z3 n+ a7 |( e' K- M& P5 f U "%d\n", ret);( s+ ?! n: r# B! b; A* R
#endif
. a! c6 k6 e; J7 z7 ? ret = platform_device_register(&da850_evm_tl_leds_device);
8 U1 t5 M: ?. P! V8 l: Z/ D* w if (ret)
1 ^ J: e6 a1 b+ I" n" }6 a pr_warning("Could not register som GPIO expander LEDS");) O' O& g; n0 s# s- t
else
2 g$ Z b8 M* f+ H& r$ v+ f8 v! w7 ? printk(KERN_INFO "LED register sucessful!\n");. d# Z# W; \: C5 ^! u- s4 T: r
}2 D1 N* }. L: l, u
return ret;
. p' Z* ?; q3 Q$ n}" P( N5 E7 A% U( M3 H4 W# w" U
1 {6 t5 \% o4 ~static void __exit led_platform_exit(void)+ H' Y$ y* F' g9 q2 w0 Q
{
" }; b; l5 f" m9 s& H% W2 ] platform_device_unregister(&da850_evm_tl_leds_device);
, n2 `, q! l! c( F% @7 ~* j
9 @6 ]) D; m5 p& t7 D$ j) U% @. [5 @7 j$ h printk(KERN_INFO "LED unregister!\n");
7 {4 T/ X( C6 I}( J" K* w. M. W# A8 V I, M+ h5 L( x
' Z$ O5 W1 I6 R; p3 y6 E! [
module_init(led_platform_init);) X- C9 f- n7 u
module_exit(led_platform_exit);: J' F+ x; }! b5 j$ {1 Q- `* I
( x$ |( k, B& y, s: _6 R6 mMODULE_DESCRIPTION("Led platform driver");
( l3 g( \, V) rMODULE_AUTHOR("Tronlong");
, W4 {. T1 e* R: u* K4 C: AMODULE_LICENSE("GPL");
- M @' T9 }( g k# ]( L8 _6 x5 w% b" V* T; B. d; F
|
|