|
|
求大神给下面的程序做注解,请稍详细些,谢谢。 t5 ]/ B8 g* G# z* L
#include <linux/init.h>
# ^ r, m, ? b9 q- J& s2 _! y! F8 z#include <linux/module.h>
9 D1 \ Y2 @" I- j#include <linux/kernel.h>
( a% q7 g3 r6 Q* P* G- ^#include <linux/types.h># ~! V$ T# s0 F& ^# B9 s% t- t4 q
#include <linux/gpio.h>& \! [" S! L7 H7 w, h) `) b* \$ ]
#include <linux/leds.h>
* ]5 Q- P; c/ k: o#include <linux/platform_device.h>& J% E3 U$ t) V9 T! v3 ?/ b
/ s4 }; z* H+ g3 w1 z5 [
#include <asm/mach-types.h>! ]! G Z7 i: X5 ?, B! Z
#include <asm/mach/arch.h>
" @* K4 q9 V+ w7 A#include <mach/da8xx.h>
& e q6 k. e. g: r! I#include <mach/mux.h>! d# J; Q2 `7 p% Z9 D
0 c E3 j- k3 I; \#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)# i# N- x6 A7 t0 G
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
$ H/ L1 ~3 {# Q#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)4 I$ s* ]* m4 V( @, W2 n4 A) _! S
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
( }0 \( f. w& p3 U9 [
) [1 {" i1 H9 U. o/* assign the tl som board LED-GPIOs*/4 Y I' _. [7 k r
static const short da850_evm_tl_user_led_pins[] = {+ N- b! ]3 N, H8 F0 S5 }6 p: s
/* These pins are definition at <mach/mux.h> file */! n/ f5 G4 s4 p& F" i
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
/ s7 l+ i& k% I6 D -1( T+ n! E% O7 N4 q
};
' ?) T8 ?; Y' d: C# i! N* X
0 R: i9 B Z3 lstatic struct gpio_led da850_evm_tl_leds[] = {
, K4 y* p4 b% W" {: t5 I {5 x1 z4 |$ B0 j+ N% K/ n
.active_low = 0,$ O5 S- r$ x9 ~; N
.gpio = DA850_USER_LED0,
4 Z/ s8 J" X& o6 K. V% [ .name = "user_led0",
. Z% w' q% _) _6 @. T% Y' z .default_trigger = "default-on",2 C8 H5 Q9 v, T s. t) m
},
; D4 W+ j& U' J% `4 y1 b" v7 ` {
9 u& y7 w# C" g+ Y; S .active_low = 0,
% Y6 {3 c5 D" k, s' p .gpio = DA850_USER_LED1,
- M/ _, K$ ?, S .name = "user_led1",) N& c5 B1 L) ?0 [' ]4 j- b
.default_trigger = "default-on",
/ Y4 W- M. L2 ]# D },, d7 \2 Q" v( h. z K
{5 W7 W7 C- s9 C8 h% V! n
.active_low = 0,
0 _* |, s* O7 d5 h7 H .gpio = DA850_USER_LED2, A7 u& S. r! C% T1 }$ H
.name = "user_led2",
' R: q7 Z4 y( K3 j! Z& D .default_trigger = "default-on",; I0 z9 l e6 |) h! W
},
q% D0 s* R4 d" I% y z7 T {) ~* ^( a2 p+ d, n) o9 C$ d, D }
.active_low = 0,
9 G( S- | x6 U6 @. D .gpio = DA850_USER_LED3,3 N' W* `9 R" ]5 S' d2 n
.name = "user_led3",
" p. z! g4 K% |, Y" j .default_trigger = "default-on",2 J& F9 J7 j' d7 }6 q- j6 ?7 w
},% s) k; i2 c9 q3 B8 n1 {2 C
};# g. t9 K+ _% X% D1 h
% T# [; v8 ~ i( bstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {. n3 ~$ [ m1 m t: c
.leds = da850_evm_tl_leds,
$ o8 M, [+ F1 m .num_leds = ARRAY_SIZE(da850_evm_tl_leds),$ i: a6 a9 {+ M; H# i- D2 x+ ]
};# W. T6 i8 Y% I2 h( U# k
" i5 L' X1 `: n7 [static void led_dev_release(struct device *dev)( B7 m$ p7 A0 S& w8 {# ?* s( P! i: O* ]
{# j- p1 j+ f* d4 `
};2 M" D4 P: k& X# \
3 w! ~1 {8 X9 J( Z/ ]: W9 l: W- b# R
static struct platform_device da850_evm_tl_leds_device = {
6 ^4 H) X9 @/ G# M+ @3 u. g7 Q, Y U .name = "leds-gpio"," I! y7 S$ R4 w% U0 B8 W6 A
.id = 1,4 ^. A9 P' b. @* P c: T; |: j
.dev = {
" F! q0 y' D% |4 O' f8 Z$ g# \ .platform_data = &da850_evm_tl_leds_pdata,3 _; F9 C& O2 K7 r& q9 _
.release = led_dev_release,
; `& x3 d9 \8 \$ o8 Z1 C# }2 X. ? }
$ B/ [; \. W/ n% |+ p6 _: {; g7 W};
+ o: D: X9 Z: ]7 F( c7 q. q) W6 ]8 B" F9 g5 r
static int __init led_platform_init(void)+ O, p J6 y b
{
4 J: p. [+ ?. J, Z int ret;$ f1 n+ g" L4 {
#if 0, R1 X6 a+ S1 m6 h! T$ T0 a2 K
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
. V/ B6 D0 j' {! J if (ret)$ s1 j4 F- I( b5 d; h# ^" u) R
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
2 X' J, V3 @+ l, D/ \ "%d\n", ret);: ?- u4 z1 e" W8 |; T: w
#endif
, P: d4 r7 {5 h% M" ] N# O G6 W( G3 s ret = platform_device_register(&da850_evm_tl_leds_device);
8 v" ~0 ?& z( W/ y# D if (ret)
1 f: G0 u& E* H) J \ pr_warning("Could not register som GPIO expander LEDS");
& V% J- ?1 r$ _! P$ q else
$ T9 |6 f/ r5 X% ~6 p9 C: X/ ]8 I printk(KERN_INFO "LED register sucessful!\n");9 Q, B5 s& H! y3 g% ^
1 A1 n5 W! w. j: U2 N, Y
return ret;
3 |- G. n( T2 B* y}
% B5 L0 w' G7 F" s6 Z9 r
3 @& o1 K, g8 tstatic void __exit led_platform_exit(void)" y- F2 H5 s1 s" q3 W
{
7 R+ c- h$ G/ ~0 o. V$ ]% T4 L platform_device_unregister(&da850_evm_tl_leds_device);
1 @. p+ V" f, Q3 F- u1 z2 D% O
) T& {" n. D" i k# f printk(KERN_INFO "LED unregister!\n");$ }$ P3 b8 p0 x2 @. @ f; _
}
6 y7 i! C9 m1 `/ L* h* b( [2 Z3 G: D. S% W+ b& ?$ a4 b4 W) ?
module_init(led_platform_init);& U+ F* i' s0 v& C D
module_exit(led_platform_exit);( _1 C, Z% v e, k/ |# o7 v# F" X4 k
7 @4 W' d, B9 A6 U& PMODULE_DESCRIPTION("Led platform driver");; N, M- F+ Y& |& N
MODULE_AUTHOR("Tronlong");; o+ G- X9 F- Y O2 d( ~. k. H
MODULE_LICENSE("GPL");
2 f0 F' v0 k& A: H4 J
7 ]* M8 z& h% J' G6 b" \ |
|