|
|
求大神给下面的程序做注解,请稍详细些,谢谢。4 s" s+ g8 c; l9 L3 i% l6 N# \
#include <linux/init.h>
) I+ l1 ]# _% T# L3 i#include <linux/module.h>
1 [' P9 C: i5 G P! Q% h- E2 Y#include <linux/kernel.h>
- r, l! f: Y+ Z$ i#include <linux/types.h>
/ t4 v+ N. `+ p, W) v* `#include <linux/gpio.h>
: L7 U* G2 a, ?( g#include <linux/leds.h>( j: n! p; c' e# r1 J$ ?( i! d
#include <linux/platform_device.h>/ w( @! x5 o+ c/ |) U
, ?# V9 ?; R! s2 z2 o* D4 [( v2 h
#include <asm/mach-types.h>. j: E1 H( {& }3 Y4 E: \9 I
#include <asm/mach/arch.h>
/ e; x Q: [: t1 H#include <mach/da8xx.h>
* r- h% @) ` h" T2 h% S7 h( }#include <mach/mux.h>
, ^* Q* g# Q; D9 n$ X$ \0 b. V( y
4 _1 P2 K: `; Q; x#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
6 @8 D3 l# J& V#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)5 A. ?3 e9 N7 d( L5 Q5 U
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
5 ^1 L$ v0 v1 q' n- w, O#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
- V! I( q C: k2 J% S
: L5 `! A5 M, D2 }+ V/* assign the tl som board LED-GPIOs*/
# @9 n3 P. {. ?6 n/ estatic const short da850_evm_tl_user_led_pins[] = {) {8 R& D' g/ J; m8 V( N0 f
/* These pins are definition at <mach/mux.h> file */2 x, c- D2 x8 R+ C' l
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,5 N# U% X% z2 A* q
-1" A5 K6 A8 G2 J* Q8 B4 _) M
};9 K+ T% m5 L% [% P" x W
* I0 N/ ?. ~8 z9 M
static struct gpio_led da850_evm_tl_leds[] = {4 u& C% n! _# o$ C
{% `6 o- k2 R, l! @
.active_low = 0,4 F% x2 E( `0 q
.gpio = DA850_USER_LED0,- V- l8 x, O: T ~& G) Z
.name = "user_led0",( n& Q$ R) l5 l! d2 m+ G
.default_trigger = "default-on",
4 a6 R, R3 f, b' j( {6 }" S5 r },
+ e0 d) r. H( M, X. k) x {
! a5 ?; K( b6 ?; y' M .active_low = 0,5 U7 F5 B" F7 d) g( e1 {' q" O
.gpio = DA850_USER_LED1,6 m. t! z2 O% m+ _8 C
.name = "user_led1",
. o2 \0 M9 z6 m) C& b .default_trigger = "default-on",
9 a! _# i) n% i6 d },, p! J) V |; o4 \, ?1 X) u
{
; G6 d l0 d6 [* i& x1 y$ y .active_low = 0,
% u i% o9 F5 ~4 u .gpio = DA850_USER_LED2,# H' j% d$ p5 ]
.name = "user_led2",
9 P4 L7 r' @3 @- Z9 a4 f( D .default_trigger = "default-on",+ j. ]' ^- z/ \* E1 S
},' _' [0 ~$ \' v5 F1 S9 e) I: U3 k
{0 C+ d1 _+ T; g3 _3 Z6 C3 B
.active_low = 0,, H% B. C7 B( \7 Y& t2 f
.gpio = DA850_USER_LED3,
' m5 m: }3 n v7 p& L ] .name = "user_led3",3 q9 J- z% B* p% c6 y: Y
.default_trigger = "default-on",- p) ^8 q1 p' }$ J- o
},6 P0 x) a( F: D9 i: j
};: c5 {1 g' }$ P. R+ [1 g2 v
, m& w5 O' Z8 l1 \+ W9 pstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
4 @3 H' N* x6 H .leds = da850_evm_tl_leds,
8 ~* A2 t0 G# W# c) v: Z# b .num_leds = ARRAY_SIZE(da850_evm_tl_leds),; f" ~4 a) }& F# d( e
};+ H. S- c4 O: Z. J# V' J
7 F: c) ~: P1 {' b ^* Mstatic void led_dev_release(struct device *dev)9 l3 ]/ q! e& ?. h
{- L7 E: x2 h3 s2 c; T: L6 N1 h8 C: Y
};
8 [: ]7 P0 T7 N+ \; u- G
; H1 R+ S' ]0 c6 T# d, i+ T( h% _static struct platform_device da850_evm_tl_leds_device = {
0 W6 ^+ b1 h( V+ L: l' q& A .name = "leds-gpio",
+ H) A* J2 p, S* _+ |1 \ .id = 1,
2 x+ c: A; ? v .dev = {
) C4 g( r0 i9 _8 ^" ]4 ` .platform_data = &da850_evm_tl_leds_pdata,
4 N$ q3 K9 K. S% ?% D8 K9 s% g .release = led_dev_release,
! ? w. v9 k4 S; } }+ h, v- T$ p4 ] \
};( q6 d1 }" f F1 X
1 S* W3 @4 o& V' Ystatic int __init led_platform_init(void); ]4 [$ v) E. M7 K& i
{
. c5 a9 b- k4 Q3 b- Q6 ~ int ret;1 A- u9 A5 Y5 |; L x. O. j
#if 0
' y% R8 `$ k; a ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);, \: E _7 W9 _5 z
if (ret)
) _1 m, Z p1 P7 |- P pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
0 E, N- R( H* ?0 a% q$ H, x+ e "%d\n", ret);
/ F. E) q- \/ k/ t; U. N#endif
q s$ l ?: E7 i! P s ret = platform_device_register(&da850_evm_tl_leds_device);$ n2 j8 `' A0 E% I. A
if (ret)
- ^. \4 H$ ~) [. h% s6 ] pr_warning("Could not register som GPIO expander LEDS");/ V2 L+ V! P& u/ W$ q) [) M7 S
else5 S% ?2 R% |( o! A; [
printk(KERN_INFO "LED register sucessful!\n");
1 P0 n( @6 o& t+ x: {/ V3 H
4 e! M7 R1 T( @7 `9 P/ X return ret;0 z' y! B9 H& q7 l. {
}1 h/ v$ I0 K7 A7 D* W5 b* T
( k8 i. d* r& D* X" b
static void __exit led_platform_exit(void)
& C, Y3 m& p6 m3 b& }{4 r3 }. ?0 M) ?, B9 r. l
platform_device_unregister(&da850_evm_tl_leds_device);
; u: G' T" ^8 I! N# m5 B7 e$ x" V
3 G! I$ g* M3 Y% w7 A printk(KERN_INFO "LED unregister!\n");
% A9 I& h: n) F0 t}
Z2 O* T f2 v- Y* H# i6 k, Z' G* L( O# [( q
module_init(led_platform_init);: N" C( [6 z+ c# k
module_exit(led_platform_exit);5 ^; V$ r3 m7 ]7 G/ \1 J
) C* V3 x; }4 iMODULE_DESCRIPTION("Led platform driver");. T8 t$ e2 D3 ^6 [
MODULE_AUTHOR("Tronlong");7 s! R- O$ v \: i
MODULE_LICENSE("GPL");
* E2 j) V' G/ w/ p
0 }, w& ]6 y1 F; o |
|