|
|
求大神给下面的程序做注解,请稍详细些,谢谢。8 ^" j/ \% j* r7 i, D9 F$ s
#include <linux/init.h>
, {4 {. {& k- T& |7 j#include <linux/module.h>
6 v8 p: O) N/ z, D1 Q7 ?/ f7 i/ t#include <linux/kernel.h>
# J9 P2 A P; M/ m#include <linux/types.h>
9 y6 P% F$ t. I; L5 @; P& A* ]6 A#include <linux/gpio.h>. U% M) ?4 V# N2 Q! P
#include <linux/leds.h>
7 }+ |* X( Y2 S' f4 e; k) a#include <linux/platform_device.h>& S' d2 [: u9 P' B) D/ L/ j. [
7 |# K7 F1 @4 ^' e% E# Z
#include <asm/mach-types.h>
" C" v. _: |. a5 a1 W& [#include <asm/mach/arch.h>. Y- C7 A: h4 }" S% J
#include <mach/da8xx.h>9 o: I+ T; _. v% |; T
#include <mach/mux.h>; n: B2 T7 s% H. I
8 Z, K. S+ s+ y
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)2 i% |- C V; f5 e. `1 K2 R1 h
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
3 }! E( P6 G( @#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)3 g% A; J3 P0 G* X
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
' { Q+ U( a2 Z- _* L
y$ t! y0 R( b$ {0 ~) i/* assign the tl som board LED-GPIOs*/
* W8 @. s4 v3 Y2 q, E3 E$ Sstatic const short da850_evm_tl_user_led_pins[] = { X- a: J' q( x9 @
/* These pins are definition at <mach/mux.h> file */# v. Y. g$ D# x! D# ]' r
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
1 M1 l/ ?) F" X+ a& T -1
% Q& v" |7 X/ W: E: q};
) u5 w" Y/ F4 o& {
; e7 I5 W/ v. B4 t6 kstatic struct gpio_led da850_evm_tl_leds[] = {7 m4 z# j4 {; _% X. Q
{
( O! E' s# K" J9 s9 y, B .active_low = 0,
( J$ L% I& @0 M# b .gpio = DA850_USER_LED0,; Z; R7 f8 ^5 ?% ?+ P5 m
.name = "user_led0",
" }: I3 H E. o* Q3 l% W .default_trigger = "default-on",3 X, p' I) _4 x) r
},
$ }( g2 L3 R, }/ |$ g R3 [ {3 _% W. q2 b# x Q3 ?
.active_low = 0,
- P( x7 o, [+ f/ D3 ?2 n8 d .gpio = DA850_USER_LED1,
) U# T) `3 ]5 Q; @+ }! {: |+ r .name = "user_led1",$ }9 u4 n# m& k+ o+ q5 l
.default_trigger = "default-on",5 K6 }9 V: P7 c( Z4 R5 D( \
},% H$ Q+ ]6 q8 |& y
{
% ]8 i: o( t* q4 w- Q/ M; z .active_low = 0,' f1 ?* E U7 i# [: t( c& j
.gpio = DA850_USER_LED2,' [& f# Z! U- Z4 S$ U
.name = "user_led2",
& c/ H3 ?2 X M A4 @ .default_trigger = "default-on",
6 n; K8 H: o) F7 M3 S },! x5 k! ~ Q* R `" ]% P
{' A# g& U9 I0 I% s& F
.active_low = 0,
5 ]9 Z2 @& c7 t' w .gpio = DA850_USER_LED3,1 ~" B$ ^+ T* _2 ]
.name = "user_led3",! Y! o3 g4 g+ l* i0 T, ?
.default_trigger = "default-on",7 S8 C" D2 f. x# `( C
},
, E/ z% o* [6 U( d2 c0 Q. ^};
6 B. }1 F0 M/ p! c5 o) T' F. E. p& s6 Y* p0 S
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
0 Y3 c: R% O% ` H. n .leds = da850_evm_tl_leds,
: i6 @4 K/ q) p .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
( L# S$ x3 h1 Q8 W2 D! L5 W};
( ~) y& g. |5 M# Z
% b5 y; @ n( F% P2 p5 @$ z! Dstatic void led_dev_release(struct device *dev)
6 _8 l' \$ f, Y{1 n- {$ ?; W. X% D, O3 I
};
$ L6 ?. o; Q( n5 ]" k4 Q3 e' R1 W( n0 a
static struct platform_device da850_evm_tl_leds_device = {
" {& U) ~9 z* S j6 C9 u .name = "leds-gpio",6 K, n9 u1 Y# H" Q0 @8 m$ c
.id = 1,, R, r+ n0 Y+ C I8 ~
.dev = { k2 v% f) z. Y, ]5 b& y4 T
.platform_data = &da850_evm_tl_leds_pdata,/ @( k& s( `. S% r% e
.release = led_dev_release,
, n9 L7 n' F- j1 h& G* |: ? }1 [9 j* J, @* R0 v! T; Q
};8 B7 J. R4 U! L, T& M
0 C _9 }. P6 G+ o& y: ?% U
static int __init led_platform_init(void)
3 S, b2 f5 k/ \4 w% e, c{
8 K$ V; I! J+ V: y+ G int ret;' G% o2 }; g2 a
#if 0
& l& H' N" b1 p9 q ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);" I2 }) f& W3 T8 S. |$ ^
if (ret)' _6 _8 r% g# w
pr_warning("da850_evm_tl_leds_init : User LED mux failed :": i Y; e0 Y) }7 M b) x5 Z" A
"%d\n", ret);
/ j! J! E7 w/ R# U- R#endif& Z9 Z( b; f! ?7 F. K
ret = platform_device_register(&da850_evm_tl_leds_device);8 m* E# O: l' t) C$ m
if (ret)
2 X: j8 n. s7 G! ^0 O pr_warning("Could not register som GPIO expander LEDS");. e# ~9 Z" _# P4 I
else* s0 U4 D% k6 S; V1 o3 n
printk(KERN_INFO "LED register sucessful!\n");4 P1 m( r5 y! s+ l1 i8 T" |
: Q5 `/ W9 g/ k% B: K x return ret;% T( b$ }# v+ [0 U8 p. i
}. G7 N( a, R% r, y0 l' z
8 G( M, e1 L$ a& J# g9 T$ h. {
static void __exit led_platform_exit(void)/ s" g/ f3 i4 r% U- V
{
2 \# I' G. S- C) l, e platform_device_unregister(&da850_evm_tl_leds_device);
6 [: }- r) Z) K2 F: }* M4 S: e( ^2 Q3 t' {8 L
printk(KERN_INFO "LED unregister!\n");
/ I+ @$ W9 e0 h2 ^/ U/ I6 a}' x9 D& F6 w6 @# a, \# e. g
2 ?- N, N: A: M
module_init(led_platform_init);
1 e) r" B: U' A0 c3 P' nmodule_exit(led_platform_exit);" T- W. e) ~6 |4 F6 X8 B5 ~
7 s4 k- P' U& E& [MODULE_DESCRIPTION("Led platform driver");
, I$ H% N+ c' E$ W5 B2 i; mMODULE_AUTHOR("Tronlong");
4 Y7 e5 r# b) z VMODULE_LICENSE("GPL");4 _$ D) R7 `! A$ P7 h" m
( ^ ?' j4 e1 P; n5 k) P |
|