|
求大神给下面的程序做注解,请稍详细些,谢谢。* v* P1 @0 u, M2 d7 s
#include <linux/init.h>/ U* I2 h1 U, ?5 o
#include <linux/module.h># {, a7 i1 Z e
#include <linux/kernel.h>
/ v3 g4 ?- v: U, b; Z. I% T# P/ e& e#include <linux/types.h>8 I9 R3 b/ n8 e; e7 q
#include <linux/gpio.h>% }' M) u4 M v/ d& i3 }
#include <linux/leds.h>
2 T- A# x: S; ^1 v#include <linux/platform_device.h>
) a! L$ u) j6 F* G4 U- L
5 N/ |8 F: n! Z' K0 C e2 H( N#include <asm/mach-types.h>9 O, Q$ u2 u+ X0 O
#include <asm/mach/arch.h>3 ?" b7 o. f6 T) \# P
#include <mach/da8xx.h># P8 A7 t- u* j2 }; O
#include <mach/mux.h>8 x0 a0 {/ G* s( ?( f- U" Z' s& o
: C/ s8 p$ C/ v. F. `6 H _
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
) `. m: Y; E- c2 S! ~* U! K) c/ o0 N#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
2 T) J$ r8 C; L; A#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)3 [. d# N. R* s& ^, V7 L) a
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)& R# M) v- @' x* K% Z. R( s1 }
' T6 M H3 }4 f6 ^2 ^/* assign the tl som board LED-GPIOs*/
+ n2 y. W4 J3 _: ]static const short da850_evm_tl_user_led_pins[] = {
; X4 x. A& j8 g /* These pins are definition at <mach/mux.h> file */
* A0 m7 V8 N, F* y5 t8 Q DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
' T! ?3 g$ r! X0 l9 { -1
/ D! Y5 ` v$ _; ?2 W; y/ j};6 |: ~, p; z5 {; F) }5 D: t- ]5 u
3 S2 b' b9 V1 B$ {- R/ y' s& }
static struct gpio_led da850_evm_tl_leds[] = {9 c$ h( o, I, y% c- C
{$ ^$ t1 l' R! c
.active_low = 0,
4 U8 }9 f1 O1 C- o3 o- H3 i; { .gpio = DA850_USER_LED0,
- G- {" w# c6 L- _ .name = "user_led0",, D( D9 F) P \; S+ f+ S
.default_trigger = "default-on",
' O. L" {/ F. W' L6 j* h X0 `$ V },& V. _; I7 z4 ?" ]6 O/ D! G' T
{
* y. ~5 W- v9 N3 V# l& Y .active_low = 0,+ u; Z7 z# O6 \( ~! @" V' q5 d4 _
.gpio = DA850_USER_LED1,
; r. P' T3 a! J/ I/ I' o- r7 U .name = "user_led1",
, I% F( I/ X/ r* I8 ~) W$ o( e .default_trigger = "default-on",$ D- _# R H/ p( {. I# M& ~3 Q
},& ` x5 b* Z# z9 \7 h3 V7 b5 ]
{; a3 K D+ z9 F/ f
.active_low = 0,+ X/ {4 s7 R- Z4 Q
.gpio = DA850_USER_LED2,
2 n" ~; l. \8 r( q, n" w9 f0 ~ .name = "user_led2",( | }8 D& z9 L) B9 y" N0 P
.default_trigger = "default-on",
3 G9 b6 Y6 c0 |9 \* {. v& k# C },$ D0 n4 b4 r* E! z: Q' u' D# s0 U
{" R: a4 s* R, O! |
.active_low = 0,
2 n. k% x: c$ ^. m* I7 V .gpio = DA850_USER_LED3,
& F6 S- h+ {! Z' i$ i .name = "user_led3",4 K' `7 z* j R1 G, w% _
.default_trigger = "default-on",3 n y) o2 k1 I! s4 u" }/ K% n
},
7 {* b0 | O5 Y6 N# g% q};2 D9 ?2 X- @, o/ `: a V
+ Y; q* M+ Y9 H) i1 L2 Q* Q% ystatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {+ _6 R4 w, ]' M& K% b3 R. d7 Y* z; U2 `/ a; t
.leds = da850_evm_tl_leds,
: Q _4 V% R. h% P6 | .num_leds = ARRAY_SIZE(da850_evm_tl_leds),+ m0 o; P; Y* T+ I+ E2 u2 K
};
% J1 Y+ X& z0 g! s- u1 E
! O7 {$ }( `' v. @static void led_dev_release(struct device *dev)/ X, n" ]+ E/ F, @0 G. z3 v
{) H3 X0 l \* @" _
};
# H ?% o- x6 |
$ y/ Z+ {1 B5 d, g: wstatic struct platform_device da850_evm_tl_leds_device = {9 N" m" ?) N c3 i7 Q
.name = "leds-gpio",
8 ?! a4 D2 Z- W6 V6 e* ~ .id = 1,
4 g9 O! q- U3 w1 L .dev = {3 X! F- S8 a& @; S8 M2 B7 }8 q
.platform_data = &da850_evm_tl_leds_pdata,2 P, ]4 O/ ^) c" y7 r, d
.release = led_dev_release,
4 G: p2 C5 g/ A/ c; v }
( F: V3 v9 M' j3 l};
$ x2 [! Q+ A( t) G. H4 `
4 R" P1 N6 {" q4 I6 _6 Tstatic int __init led_platform_init(void)
* ~: O; K) W2 O) i0 N) [2 v: ^/ S{
8 N) M3 X# J i8 D int ret;, ]" f4 }+ ^" c- G$ p6 D
#if 0! x" a+ W! R$ s3 L# {7 t
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);9 @4 q0 L% ^/ e
if (ret)
% q3 S% Y* ?: N: n/ f' _' l% [/ j pr_warning("da850_evm_tl_leds_init : User LED mux failed :"* Q% U7 B3 k$ ~/ p6 @, a
"%d\n", ret);7 n$ H/ ?6 B; c& a. D% r+ x7 ?
#endif, R0 e9 } r7 c/ z$ D4 V0 M0 u
ret = platform_device_register(&da850_evm_tl_leds_device);) l' [2 ]5 ^) @0 H, Q
if (ret)
4 d. W4 i8 [8 M) ? } pr_warning("Could not register som GPIO expander LEDS");
* ?% \. A3 i" m else
6 K2 V! |9 C" u2 M0 N8 F4 Z0 f printk(KERN_INFO "LED register sucessful!\n");% R& Z: z9 e0 }" v
6 K1 J# M) R* d9 c y: }- l
return ret;/ C, D9 G: K. {2 i" m( q5 M
}
4 A7 }. k) |% o6 ]
2 ^- d. p- x# Q0 ^0 g$ I. O) Vstatic void __exit led_platform_exit(void)
+ Y8 Q7 _) p# }- {5 [( h8 r% r{
) H- B4 W# G' q8 P$ G+ O# W platform_device_unregister(&da850_evm_tl_leds_device);4 s s' Z; @0 X5 e/ c! Q9 s8 X7 y' Y
( g8 u& v4 e$ y
printk(KERN_INFO "LED unregister!\n");
" A. N* o! H; A' Q+ ~+ s+ X}
4 j& e5 P8 \4 H: n- P$ B9 |+ z) N3 g" L b6 A
module_init(led_platform_init);
' t3 u H: b' r, Xmodule_exit(led_platform_exit);
: ]* s/ h4 Q9 p1 S( N+ h1 _2 W; m6 i" `6 I* B5 {, {) f
MODULE_DESCRIPTION("Led platform driver");! r& h( n/ m2 [4 B p8 o
MODULE_AUTHOR("Tronlong");
8 L1 @* \4 @# I" PMODULE_LICENSE("GPL");
$ r/ X! u3 Y m7 w" ? I/ H* J: f( w( q/ s5 A
|
|