|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
0 x: h) E: N. Y+ I) b#include <linux/init.h>: O: L- t2 u/ ?, S
#include <linux/module.h>" l! D( `$ b! b( u' s% p5 o9 _6 n8 \
#include <linux/kernel.h>
. F' s) X# K2 F) ]#include <linux/types.h>$ w9 d1 z" l, y' P# c$ m5 A8 |' m/ O
#include <linux/gpio.h>
9 a* ?, c+ [% D* q#include <linux/leds.h>3 m+ d- t& I9 a/ s& _
#include <linux/platform_device.h>
& R- _! Y6 o6 B+ _2 [1 `+ Z& g; a
1 {+ c5 [5 n5 g" Y#include <asm/mach-types.h>
; N! B. d$ g( C- d2 l& D$ x7 l% ~% h#include <asm/mach/arch.h>2 I+ M/ H% X7 H$ n5 K$ w
#include <mach/da8xx.h>; T) m( A. C J
#include <mach/mux.h>
( M, ~4 J) U0 e4 ]: p
' B. Z- Z/ s- M4 t#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
6 a) w6 ^$ r7 x#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
* G/ [( k0 g9 V) @* K#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
4 B# ]" B, u/ u0 U l#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
) q* V2 G# A- L @0 U C! _
% w2 w1 D; e' ^5 F* A/* assign the tl som board LED-GPIOs*/0 f: W7 W$ ~ J9 i" J1 y7 C
static const short da850_evm_tl_user_led_pins[] = {- y+ ^- j. a) G* o* f
/* These pins are definition at <mach/mux.h> file */4 z$ G; `1 T5 d9 x% P) U8 b/ @
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
6 J% A; t, ^! `6 y, z -1
" Y' g1 j4 @% ?4 U. I};
; N+ [; F1 D+ P' J8 p0 u( r! G% y6 B9 r' E9 p G; ^
static struct gpio_led da850_evm_tl_leds[] = {/ n/ R, u" i, @1 I) g
{
& W/ c. d( g- \7 W! L .active_low = 0,
' \5 P* f6 u8 i: y4 \ .gpio = DA850_USER_LED0,5 J* e0 V+ ^* ~0 ^9 n3 k
.name = "user_led0",) W# D2 n# n) M9 [
.default_trigger = "default-on",
4 ^6 o4 q# H4 n1 ~; q3 ^. o6 v },% |0 B5 e' [8 r0 w$ r- v
{5 ~ r: b: _* V$ e$ Y
.active_low = 0,
& P+ @( c/ d3 y0 Z2 `& g' s .gpio = DA850_USER_LED1,3 k+ q/ r1 d5 R
.name = "user_led1",
1 \1 R3 G! i' D) t .default_trigger = "default-on",
: p( l' s' q& W2 C },
) p; c8 i$ f* v" \* T o {
* ?5 ]6 |" j: e; g: T/ u .active_low = 0,
1 I K0 s% @: v3 j .gpio = DA850_USER_LED2,
1 h8 ?6 e2 {: i0 }6 m; |$ }# p .name = "user_led2",( v* a5 b. T' p6 Z* k$ v
.default_trigger = "default-on",
6 P8 [/ H9 p/ C) [) ^% q& F0 L },
. e$ |6 N' w% l: r {, f# P8 V& S6 P" I
.active_low = 0, S6 L4 W) ^4 T6 S/ i9 p
.gpio = DA850_USER_LED3,( T- p, }) b0 y5 _, h
.name = "user_led3",7 e! ~9 Q# A8 E X8 ]( }! G
.default_trigger = "default-on",* Y; m j4 B, E0 G* U. |
},3 d- f8 L: c2 w [- I
};* H2 m" p& ~& l& g5 i
, X9 C: E, [8 e# x7 b- J/ a1 M/ b
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
2 I9 ^! [5 L5 J5 [; s ?6 k .leds = da850_evm_tl_leds,
, U1 s f* p3 @3 Y: H2 v- _0 t .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
* A7 Q2 e* I) [: ] I$ [( p5 w5 x};
1 Q$ T; h9 X" C0 r9 `4 _" H4 ]2 L
& V" f- _* O# ^7 y2 O. y; Qstatic void led_dev_release(struct device *dev)& w( ^9 _( U. C& c/ ?- ]6 O7 Z
{
: L1 I: @0 n7 t' `! M; Y};* A$ Q6 n- C. ~
: ~" u- I* C; A! _8 g0 _1 m5 V. {
static struct platform_device da850_evm_tl_leds_device = {) `5 y& P2 `% }# a
.name = "leds-gpio",& J/ Z; R' N" `- S7 ~# |3 @0 N
.id = 1,( j) {+ S/ W- j: R% f4 K5 }
.dev = {: h1 T3 E& S* I' W
.platform_data = &da850_evm_tl_leds_pdata,0 \# p% b8 ]" w' \
.release = led_dev_release,
. H+ l5 k+ ]' Y+ C2 }8 z }
# [2 _* c. [: a! L2 @' M};
a& r( g" y. `4 z$ \* j. T3 t5 I+ m* V% Q; w
static int __init led_platform_init(void)
: b9 K5 t; E" n4 W2 g: s{
) Y% X8 ?- N! J$ j int ret;
( n/ ^+ V# }% }/ K8 h#if 0
0 V. ~7 F" _' ` ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
9 z: _1 ]/ C9 E( Q* t* l# u if (ret)
0 U. p: P# A( z- U pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
+ h4 }" ` b: W& N "%d\n", ret);
& L8 C* H( T6 g$ b8 |#endif
3 e* ~3 x# J( o1 f4 ^9 N7 Q ret = platform_device_register(&da850_evm_tl_leds_device);
& S% F \2 R4 H! Z5 g! ] if (ret)- @2 X# L- K$ M9 ~9 Q3 a
pr_warning("Could not register som GPIO expander LEDS");
" `! j* R! t0 g2 h; Y- V0 j else
- K8 w, y2 n. P' W+ U* N, \: U printk(KERN_INFO "LED register sucessful!\n");/ S% _ q# N5 o5 M' @
5 [) M: ~$ V' B5 M- ? return ret;
0 s& `) }% [* g: U0 u}- A5 L. T% F% H
" w* y2 ?& i* O0 N8 ~9 C7 w
static void __exit led_platform_exit(void)
7 B) \ }3 C* {2 j3 {6 R* q2 m{
9 a- M6 |8 d* \, | X+ p c- W* ] platform_device_unregister(&da850_evm_tl_leds_device);
/ w3 D) V0 H( i( m. U* |! ]4 ~5 f8 g
( V7 y/ h" x; i+ Z printk(KERN_INFO "LED unregister!\n");
1 A C4 U& J" |: ?$ |: _$ G}
/ v9 |1 X% u, z3 k- U6 l
6 \( \2 l( J: x4 `6 [- {9 Dmodule_init(led_platform_init);$ q8 z% T3 e6 F- R8 B. ]
module_exit(led_platform_exit);& i! ?8 c; F) {! @5 L
$ ~( ^( C0 E) J$ X3 j# A% }) e5 X4 t
MODULE_DESCRIPTION("Led platform driver");# R% X" j% ?' A$ e3 w# ^( j8 a
MODULE_AUTHOR("Tronlong");
6 M3 Y( K) F+ E6 C& _MODULE_LICENSE("GPL");
1 _) _3 A+ ^' w* p6 T
) @5 r9 a5 |5 X |
|