|
|
求大神给下面的程序做注解,请稍详细些,谢谢。) x) U: l+ {8 s: E( \
#include <linux/init.h>$ o3 T/ g! U# ^8 z a
#include <linux/module.h>3 P3 W. x/ R8 j
#include <linux/kernel.h>% V1 E" g5 L7 ]3 y5 n8 D+ X
#include <linux/types.h>8 g$ k9 Q8 |1 K: k$ c3 R
#include <linux/gpio.h>
" c" L+ `3 @: F4 H7 y#include <linux/leds.h>& R( x1 D, A9 ^4 G" E, t
#include <linux/platform_device.h>
4 Z% m7 K' [$ R9 S) j
% j' Y3 `$ g b0 V0 X#include <asm/mach-types.h> t. Z% D" C0 |; \2 D3 ]2 x
#include <asm/mach/arch.h>
3 C. D# E& k1 M- @1 R#include <mach/da8xx.h>
" a+ X7 I+ N! b! P3 n#include <mach/mux.h>
0 s6 `' _) b$ F' p1 |
5 X7 |0 ~" J) L% n4 ?1 T$ ]3 R#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)) n* W' c( r+ C9 I
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
; V8 p& }* R) ` u0 A4 v#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)1 H3 _( h" z8 v/ S$ m
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)8 h! ]1 f% S3 |1 p9 c4 q4 j4 }! j* b* M
+ F* E& Y5 x/ M9 C
/* assign the tl som board LED-GPIOs*/9 e; v' d2 j8 P c$ G
static const short da850_evm_tl_user_led_pins[] = {. ?! p" ~, j; v5 s- p0 {
/* These pins are definition at <mach/mux.h> file */
0 U7 v; O) q# x8 @# r DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,) U. p. z! |2 z
-1
( c0 H# B2 q( x s, q+ d+ P};
0 @! X2 a& ~# h. r! w+ v6 O* H/ P0 _8 Z. f+ ?
static struct gpio_led da850_evm_tl_leds[] = {
3 g4 M# H6 @; V* \: b' V; \1 H {
5 }$ H9 @9 y" l6 { .active_low = 0,* ]9 t' _0 h q& \
.gpio = DA850_USER_LED0,% k( k9 {' K; x4 H) l
.name = "user_led0",) Z1 Q' J4 D, k8 Y
.default_trigger = "default-on",2 h* m) i3 Q2 y4 l9 r
},
' A" Y4 Y& n( x f5 g {' C9 |2 C! K$ y7 b
.active_low = 0,
7 t2 r" I& F8 C! ~ .gpio = DA850_USER_LED1,% S$ p) l4 W7 n6 N4 x1 r6 k2 O6 `9 F' z
.name = "user_led1",- b O3 o" j7 J! J- e
.default_trigger = "default-on",# [! u2 f6 t, P& @$ l5 i
},8 |# I* l2 E5 [* y% w/ m
{ e5 Y# |$ G8 W
.active_low = 0,
8 Z+ M. \' P; @- Y6 w8 E .gpio = DA850_USER_LED2,
* @ u/ f& `% e( C1 i .name = "user_led2",
6 K, c* \' x- S+ n- F; m1 k _1 n$ G .default_trigger = "default-on",! a2 V: Y# H' ^& Y1 N
},
2 C, G' E& B2 Q$ K3 [ {- K8 [+ b9 n5 U& {* R$ F
.active_low = 0,
: y- Z3 z) @+ m+ k .gpio = DA850_USER_LED3, s( ^$ ]. f- t3 A6 |) R; i& a3 U
.name = "user_led3",
6 @ w+ h4 f; B+ ^ .default_trigger = "default-on",
x* ?5 u. P) ]' K6 G },
' H5 v$ P' C4 W8 A4 c0 B};; k \# i4 `( H8 A2 n6 j# r8 y
3 t- C' b9 w$ C9 h
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {# v$ q" i% o/ C8 |) s
.leds = da850_evm_tl_leds,8 o' q+ F) |+ ^5 Q5 J
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),$ P! z1 E9 E5 \
};0 m5 g- q7 F9 w& n0 k
+ [/ U' Y4 ]2 |9 I+ Z( Pstatic void led_dev_release(struct device *dev)
$ a& n8 V/ c' o! D+ M{
" X# A8 ]" }7 F};
1 V% E8 a s4 T- r1 e8 R3 Y% J+ {# X8 n8 `
static struct platform_device da850_evm_tl_leds_device = {" ]5 K* _1 o. K$ n* s
.name = "leds-gpio",! q) _( Y7 b$ D5 C w
.id = 1,
( v8 g V0 `9 c& W7 ? .dev = {
: C1 g: ^2 T+ }& y .platform_data = &da850_evm_tl_leds_pdata,$ m$ L# ^, u7 o# S* k
.release = led_dev_release,
S$ ~8 U p0 d/ H: o; A! @ } ^- {3 s. B! Z/ ^# ^8 v
};6 [4 m: c5 ^$ H6 H1 w
. ^; J% i; u+ K/ J& i( w: v
static int __init led_platform_init(void)
# p# S/ _0 A- P% D' m9 L{
8 a# P# o% N1 ~- @ int ret;
; H8 S( A% [9 B; e#if 0( Y& x6 _0 G4 _8 _# Q
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);, z0 p8 x: l% }4 i) C
if (ret)6 N$ y; _6 n$ m' j2 _' @( M+ p
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
1 u+ n2 p- ]* v e4 I# t) J "%d\n", ret);' H+ ^' |' K5 c ], I
#endif+ e. e# a' k6 t( J
ret = platform_device_register(&da850_evm_tl_leds_device);+ }& U8 L+ ]4 u i9 d. M
if (ret)
+ N Z6 P G+ q1 a4 o+ E1 b pr_warning("Could not register som GPIO expander LEDS");
8 W$ {" A0 i& P2 z0 I9 e/ Q else
* ~, \" a$ V/ s+ L W printk(KERN_INFO "LED register sucessful!\n");
2 r1 w$ l G/ ?( x4 ]
# _1 q! B+ ^* i7 X return ret;
6 y2 j, R2 E( y* g7 K4 O6 t; P6 ]8 u}: i7 W# D- L! z: _7 C4 R
, t; z( Z5 s) ?# D0 Vstatic void __exit led_platform_exit(void)
: u# q( O6 e! z b( c4 W{9 `( j7 x1 ]6 V$ \
platform_device_unregister(&da850_evm_tl_leds_device);
: ?. T7 c/ y; Y% l8 k+ |) \9 K. E9 J. f# h1 D
printk(KERN_INFO "LED unregister!\n");
5 U" s2 m2 l' |; q8 b8 h}
4 Z; Y0 \+ y8 J/ m" n& s; _
5 M5 b+ }4 a, ^( F7 Gmodule_init(led_platform_init);
- ?! c# m- ^% i1 V$ ~module_exit(led_platform_exit);
; s m6 V7 z5 `, D3 H" k/ Y7 }8 a
MODULE_DESCRIPTION("Led platform driver"); m. Q1 v/ ^. o3 A# P+ X: p0 ?
MODULE_AUTHOR("Tronlong");2 o: S* X) P3 X- D! ^
MODULE_LICENSE("GPL");, ?+ B8 D+ i" N/ B
5 o+ i1 A6 N4 L: R* a& I m' S |
|