|
|
求大神给下面的程序做注解,请稍详细些,谢谢。* @% E: W# z4 \; G, C" D$ A
#include <linux/init.h>0 w8 e" H) m& H" ]! U) u
#include <linux/module.h>: f* V8 H; B) l# m. p7 a$ ^% a$ C
#include <linux/kernel.h>
/ `5 d5 {- C+ W#include <linux/types.h>0 E2 f r1 \7 `4 ^& `
#include <linux/gpio.h>! H4 U$ z: a/ @# U6 }* Z% u& g
#include <linux/leds.h>
6 L. s9 i1 Z I. z#include <linux/platform_device.h>
2 V6 O+ T3 ~2 |0 M9 t7 J- b3 U7 w
#include <asm/mach-types.h>8 y% m, l' p' D% b2 H* r
#include <asm/mach/arch.h>+ K# R- `0 W! N' d8 c
#include <mach/da8xx.h>
" a( Z+ r. w. j: @#include <mach/mux.h>! L, u4 v8 [- V' a2 q! d
, f/ n) G: P: {#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)6 z+ M0 p2 H6 q
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
; H \6 L+ w* B5 M* f0 ]#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
. n: W8 e1 C( Y1 X, m+ ^#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)$ V6 l/ d: I- H
~% E/ l" J" J( `! p8 o8 c/* assign the tl som board LED-GPIOs*/
?- X3 r: a5 d1 X9 W- V, ustatic const short da850_evm_tl_user_led_pins[] = {
0 J2 p$ f9 {; ? D /* These pins are definition at <mach/mux.h> file */
6 k" ]/ i" g1 Y0 P DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
" H9 @: P! [2 a4 A. s6 W -1) P! P( l, F9 I. p# k6 r/ Z
}; I# V- C; c! L& f
! Z+ m; n, p; y& v) F2 r
static struct gpio_led da850_evm_tl_leds[] = {
3 K( E g& M% s/ Z# | {
8 W$ b: h/ k5 T: ~7 L6 s .active_low = 0,
! ^% C$ [# `& e9 j9 P/ M .gpio = DA850_USER_LED0,
: D9 Q1 X' T& f' w .name = "user_led0",
7 ]. r+ q7 J, R$ M2 h; M, u l .default_trigger = "default-on",
* P. q& c5 U9 Z8 l) | },, r8 N: H; S- N5 h m& ~
{/ C) ~: v, i, Q5 f% U) _- y# M
.active_low = 0,
Z) X# b& z, m1 Q e, T, M .gpio = DA850_USER_LED1,
! q3 a9 k5 W' |. V .name = "user_led1",
1 s4 k% f$ k- u x& U .default_trigger = "default-on",
# }$ q0 h) O' J K3 K. X# x },, Y* g/ S6 R2 }, C
{9 u+ g1 c9 c4 }7 C
.active_low = 0,4 ]# Z* r6 @, k
.gpio = DA850_USER_LED2,- b3 p! j$ H/ x" S! U$ V: r
.name = "user_led2",# E8 j: J% |; |) O4 q7 T9 f1 ~
.default_trigger = "default-on",, x9 l& i% u1 E
},
& R" Z# r/ c+ `1 U. I0 B6 f {
# V3 ]$ w8 u. d .active_low = 0,4 l+ B) x1 {5 @* ` l
.gpio = DA850_USER_LED3,+ |' r' ^% r' t. C
.name = "user_led3",+ V+ ]1 Q! C$ Q: D) B$ D2 }
.default_trigger = "default-on",
' X& R1 x* q8 M2 ]7 \( d, V5 I },9 H3 u2 N, N, }3 Z" h$ @3 V
};
( b( ?& I4 o3 h$ {! H- M/ c. ~! {6 R$ b
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {2 Q. M6 p$ r: A- V7 A
.leds = da850_evm_tl_leds,( C) ]5 _ v7 I6 L2 l5 a8 u
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
0 i: w- y0 K' h' X- Y+ W* j% u};
; |7 c) M* h! G5 W1 i( d
5 v. ?0 z( P+ sstatic void led_dev_release(struct device *dev)9 r0 C9 b# Y, [8 G: l/ F
{8 e* j4 G, H1 d
};; b# n- `* i2 q' G5 @& x
8 [3 B/ O9 U- a: N/ Vstatic struct platform_device da850_evm_tl_leds_device = {/ S1 j- L0 L, I
.name = "leds-gpio",( m& T( B8 q; d7 Z
.id = 1,
0 A# j( q2 c8 D# Z8 c/ {* q .dev = {, l a) y" ?( M6 U, _& W7 n
.platform_data = &da850_evm_tl_leds_pdata,7 ~& y6 o4 N& f) k9 c" j
.release = led_dev_release,& R( }: u$ j0 {3 q
}* I# D" a2 N9 @. z
};3 V+ b+ G l3 p
1 N2 p3 @) b7 h1 x a* B
static int __init led_platform_init(void)* w# C G* O1 g. ]
{2 Q- ~: x' B$ J2 K
int ret;
) x; S: t4 s$ t7 Z# P#if 0
6 I/ s, N; n/ v" V0 }; h& h ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);% _' [( Y* _- d( [# s: s& H
if (ret)
! w# b6 ]3 { u' p# j6 H pr_warning("da850_evm_tl_leds_init : User LED mux failed :"2 { t+ c! S% \
"%d\n", ret);7 A' j$ {' ~( ?! X9 R3 U4 N# t
#endif
0 ?$ k/ }9 O/ g9 p4 J ret = platform_device_register(&da850_evm_tl_leds_device);* X& i. r1 A6 w0 M2 d5 h# C& B! H9 `% L; k
if (ret)1 ^7 D: U) [1 |/ m. d! _+ I
pr_warning("Could not register som GPIO expander LEDS");7 h. F3 u8 o4 K
else
0 d& P% _3 m* Q printk(KERN_INFO "LED register sucessful!\n");
/ B# a! O4 V5 `9 I
# c& _6 R# H6 }9 l return ret;
0 j. t# [. _% [& x1 _( j9 X}
& e' @! o+ s. J$ ]- a! D3 B- D) R" G; Z7 F# s( r
static void __exit led_platform_exit(void)
! Z- o+ }5 v2 ~7 d1 j5 `{
/ a: E1 {5 P" d6 r+ [$ b5 d platform_device_unregister(&da850_evm_tl_leds_device);
4 V. c$ ] m, z K1 J& I3 |' s
0 G& P& A2 H* T# F printk(KERN_INFO "LED unregister!\n");) e7 T G, j: Z3 m
}8 d ]# j5 _ J+ i
+ d# p4 p6 c0 I% ?module_init(led_platform_init);# Q3 e4 I( `+ C( h9 o/ S
module_exit(led_platform_exit);" q8 R/ L! F0 _& _8 S
3 J- g- }/ b! |6 _3 X4 [* L$ fMODULE_DESCRIPTION("Led platform driver");
" P, s$ t2 o. Y: y3 Y" }MODULE_AUTHOR("Tronlong");& I/ P$ L C8 b8 d! W5 X# E
MODULE_LICENSE("GPL");* x$ f; J& m3 c% L( k) H
" J: ^8 E+ q) t6 J8 ~% h |
|