|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
2 S7 }' B% Z! l1 l9 _, }2 {#include <linux/init.h>
s, I) r% m7 i9 c' k#include <linux/module.h>. Y e. |+ J0 O1 ?
#include <linux/kernel.h>
* o" V# B' ^6 [& b* _: v#include <linux/types.h>/ S9 K: i* k$ I8 A
#include <linux/gpio.h>
2 P, w9 w B' b/ O, T8 x6 ?#include <linux/leds.h>" b- u$ j, ?3 s: e# N% r5 \2 k
#include <linux/platform_device.h>
7 f1 C# J, T2 ^. ]) N9 [ V2 [, {6 a/ u
#include <asm/mach-types.h>* m1 e, O/ }! C, q4 `9 f
#include <asm/mach/arch.h>1 t3 z5 Q7 y( T3 Z
#include <mach/da8xx.h>+ K. _7 ?6 n' {1 X) M7 Y
#include <mach/mux.h>2 b2 Y/ n0 s% ^* U/ V' N. k
6 c- y+ v) L: G/ ?7 D- a7 d/ Y#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
5 W/ }, f q, f! v7 I8 I#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)* {3 V$ c5 q8 |
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
. C$ A4 ~) N2 Q4 F' F#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)6 a' V. R% i' z6 C/ L _( M! v1 e. O
1 J7 a8 X, S7 [5 \1 e$ e
/* assign the tl som board LED-GPIOs*/4 |$ G( F- M3 x7 ]* q2 M
static const short da850_evm_tl_user_led_pins[] = {$ k8 z. Z% W7 s
/* These pins are definition at <mach/mux.h> file */
& P# b t0 D8 x* y% J DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
# G6 T u6 a- l" s -1) Y5 Z3 N+ J4 ^
};' Y& C. }& V( L: [) H
4 S- z; _0 G4 q' l9 b
static struct gpio_led da850_evm_tl_leds[] = {+ K* R; i8 X. c
{
* {7 c' v: P" ?- q .active_low = 0,2 B9 E8 Q9 g$ H1 a2 q1 G
.gpio = DA850_USER_LED0,
- L) Y f) z/ z2 y, }% X- I" ] .name = "user_led0",
+ X# X4 {. O; _2 ^ .default_trigger = "default-on",# q' P8 D ]3 v) I4 e
},5 w2 ]" x8 t. t& z% K5 q- Q/ U6 s
{
8 i" }& V3 h/ |3 [( F; m2 U# ` .active_low = 0," z- T$ ]7 f9 P% F1 n) s h8 K
.gpio = DA850_USER_LED1,
/ c8 l& J" D. ]) K .name = "user_led1",
$ m3 F, \% t8 S& `9 |: @. [( M .default_trigger = "default-on",
) i! f3 k2 w5 r' | },) K) F( {$ K5 k0 F. X
{
! ^6 e# Q5 l1 b) j/ E w5 c .active_low = 0,& W b& i+ A+ m; J4 \5 [( x
.gpio = DA850_USER_LED2,
) f2 j5 k6 @6 E2 U% s8 d .name = "user_led2",
7 O: `' ?+ X' E! X. {! G m3 I! i .default_trigger = "default-on",
4 p4 n' \0 F. B6 _1 M( ~9 }3 f1 f },8 r9 V! {# }9 Z. P0 ?5 B i: q
{* L, l8 G' x- O
.active_low = 0,
" \7 _. E) J7 A- o .gpio = DA850_USER_LED3, j6 L3 P s; O2 S7 i% `9 c
.name = "user_led3"," [0 `2 z: O7 w' Z! w- ]& u
.default_trigger = "default-on",+ U: |2 ~/ g8 B1 x/ ^
},
O# n3 O) Y0 A+ j# U" ^* Z0 `};
: h# F* G* `/ r+ @* o( X) N" A8 V% R" k. E3 S
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
: \$ p7 y5 A | .leds = da850_evm_tl_leds,: s3 b& V$ M5 m- R+ A1 x
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),) ~/ ?* N) a( E5 T v, l
};
: ^4 p6 {6 J. V% G, z4 d% ^6 C: x' Y# ~* N0 v9 A0 T
static void led_dev_release(struct device *dev)
8 O ~/ `) L5 g4 N{
( K1 o* [( ^8 O% u6 ?7 p9 |};; L! [$ m `, V& j
1 f g$ _6 p9 j# _( ]6 U
static struct platform_device da850_evm_tl_leds_device = {) x& r: D$ ~& v0 z0 b& P
.name = "leds-gpio",- W% m4 u4 J* o( U* F6 P' K8 d* b" O2 ]
.id = 1,
5 [. ?9 p5 H6 @3 i P .dev = {
+ D6 ]) x" S0 R1 D1 n: m5 p .platform_data = &da850_evm_tl_leds_pdata,
1 d, P9 O' t& L, l .release = led_dev_release,
( i# H2 H! M$ }# h8 ]2 b* e8 {4 n }
* C6 Q9 K& k7 n+ r};
% v5 C7 j, m( F% [2 ]' r: p/ b, s4 S6 y! s
static int __init led_platform_init(void)
- Y) {5 y5 [1 L' E0 t{
% }; Z: C" R' U) M5 l: j+ x int ret;7 E2 F, P% Q( J# e# l6 D# j
#if 0
& ?5 t, B" g0 J$ X ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);- E3 {' n6 \" {; E+ T' f
if (ret)
+ S8 K, n' k7 K. [ pr_warning("da850_evm_tl_leds_init : User LED mux failed :"+ J% G. J9 }3 u
"%d\n", ret);9 n& i- `; e9 i* h! l' M/ |
#endif
# D! P4 F6 m; E- m9 x ret = platform_device_register(&da850_evm_tl_leds_device);
0 y$ b0 L9 ~& C1 {7 s if (ret)
, o$ w9 U& P/ ?- p* N. c9 _! R" ~% @ pr_warning("Could not register som GPIO expander LEDS");
# }; F0 h8 A, y3 S) z% f: s! `4 z else- ^/ n0 g9 @( o1 x
printk(KERN_INFO "LED register sucessful!\n");
4 _: n2 Z, C$ W6 ~$ N7 _' X6 l
7 L) @+ @- K R$ R return ret;; h7 u- P$ j2 i3 x/ F8 `
}
2 V" V* j1 J; b6 B- D! |, f" {( e" T, M0 d. `6 y8 ?
static void __exit led_platform_exit(void)
/ q) s, U- [1 d: r{
7 s" O: c, F1 C, N; w% X4 | platform_device_unregister(&da850_evm_tl_leds_device);$ |/ o9 @( N# h, Q3 o: J
5 o# E( g2 T) `" s( x1 B5 s5 |, b
printk(KERN_INFO "LED unregister!\n");( y6 q3 x4 w& y& f! [- M
}
& {/ O: U( a/ B' A/ o
2 r. P; e# W' ]% M. Hmodule_init(led_platform_init); K( V4 J# D! `! C
module_exit(led_platform_exit);8 n& r4 D, g/ \) y: D
( ^' u; i2 k8 X, QMODULE_DESCRIPTION("Led platform driver");) F) m8 ~% R1 I" @8 w4 ~( g' z; V
MODULE_AUTHOR("Tronlong");+ V" ]( f; T8 z
MODULE_LICENSE("GPL");: M& g9 X+ L, v3 X# u5 M
, v) T' b/ z* }+ ~1 }
|
|