|
|
求大神给下面的程序做注解,请稍详细些,谢谢。( |/ F* h; B! ?
#include <linux/init.h>
3 p( f# m* U2 Q1 l" y% c% f#include <linux/module.h>
+ s o. _% I2 x/ N- R4 |#include <linux/kernel.h>+ m& ], _; d2 O
#include <linux/types.h>
2 k7 j3 M* X/ N#include <linux/gpio.h>
# H8 d3 o7 ~# p$ @# Z1 X, S#include <linux/leds.h>! c$ `7 v2 S$ ^: z
#include <linux/platform_device.h>6 B4 V6 |* {: [: v! i7 C6 D
/ K6 B, Z2 `6 l. j#include <asm/mach-types.h>& ^ h2 {- [, O- c& G+ o- z4 z
#include <asm/mach/arch.h>0 h& v# u$ i9 a! H! z5 t' m
#include <mach/da8xx.h>* A' _6 P& [9 u# ~6 g" ~
#include <mach/mux.h>
: T4 V# m/ C/ `7 i5 ?1 | K# J. ^4 T& H9 C7 W+ }
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
* H* b( p: k$ n- @ I. F% q3 J#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)) K+ H5 j- n ~
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
% Q. ~/ H5 F9 |6 j& S1 |' ]$ _#define DA850_USER_LED3 GPIO_TO_PIN(0, 2). m5 ]% P, w7 {/ `
% G: u) I' A. |6 f" w
/* assign the tl som board LED-GPIOs*/
) |$ g7 D Q `% Ustatic const short da850_evm_tl_user_led_pins[] = {
1 L; ]# o. P! B1 q5 R /* These pins are definition at <mach/mux.h> file */2 ?! {$ l; a2 g$ V0 }
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,% C3 S2 a, I& Z ^+ W4 d
-1
" d- L& E5 u3 ]' f) _};
7 q$ D% {5 I% L3 y7 `7 Q6 _6 x
" q/ _8 s4 M4 f( r8 Q0 `static struct gpio_led da850_evm_tl_leds[] = {7 ^6 L! E1 p8 @, _2 L* v1 m
{/ }( S; E8 C: P
.active_low = 0,
/ k3 }- D. i4 t4 x: ~ .gpio = DA850_USER_LED0,7 x6 D0 E! m* E; Y
.name = "user_led0",
* J* Y, A* h0 Y6 I! r) h2 ^; O2 L/ | .default_trigger = "default-on",
3 V" V* l& M1 R6 J$ v2 p" T& t },
/ G+ B# H* @& j. Q4 e% d {
1 o3 ^9 |9 F; A! }) K .active_low = 0,
+ ?2 |, n0 G7 ^# T/ g, p4 j3 N .gpio = DA850_USER_LED1,
" A0 Z" i9 o: |+ z- G1 j% g4 f2 c .name = "user_led1",
! h" z2 `9 o1 ? `. _6 S .default_trigger = "default-on",5 {7 F+ k6 t" \# \
},
7 Y I7 p( W" N {" n% ]/ Y- X& \$ ?/ `! C' G$ P
.active_low = 0,0 p9 P6 K* h0 J
.gpio = DA850_USER_LED2,
4 \1 h P W2 y4 P .name = "user_led2",
- W1 i& x5 v. ]- S- w" T .default_trigger = "default-on",
: C1 B/ y2 k8 w2 }: X },- Q7 k/ ^& q( {4 Z" {5 [
{4 h; _% k+ @. h
.active_low = 0,2 R$ N. Q. ~1 E3 F# K. t" j9 ]
.gpio = DA850_USER_LED3,
9 _& D% q O1 Z5 O1 Z .name = "user_led3",; j8 q2 Q9 ^ C* t) f6 @
.default_trigger = "default-on",0 n9 p! O( B; A( @& d, P
},8 I7 G& F6 F& S$ d2 ]
};
4 z0 s; u+ E( N; _+ ~' A4 v! L
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {7 W! ?( X W( |: M
.leds = da850_evm_tl_leds,6 L6 _# J) b. Q
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
/ w- `- |9 u* e6 Q+ G};
. \+ b; j9 C+ k: Z1 R6 |- m6 T c4 Z4 y1 J
static void led_dev_release(struct device *dev)' R" c( N/ G, I
{0 D" y7 \5 K0 S% }8 j/ W
};
: ^: c2 a; S% k! `+ k
7 j! h+ F# u1 H. S W9 jstatic struct platform_device da850_evm_tl_leds_device = {
! Q) M! r& F" y9 D o+ i .name = "leds-gpio",
' C7 e5 e) k& W/ @0 u0 J8 g' ~) K% } .id = 1,2 a' o% t2 o) a, i/ w
.dev = {
/ d! i' }. O# z% H .platform_data = &da850_evm_tl_leds_pdata, g, }. q' ~ h l" y( u6 D, e3 U! d# O
.release = led_dev_release,
& C: w0 w( w3 G) H+ r! y2 |& A }; G; R/ x; \# X* v
};
% w8 W% W' j# ~: n* T+ b; {( z! h$ ?! S$ M
static int __init led_platform_init(void), r' e& N& a- J8 ]
{6 e8 j r, [9 b" C+ v' m- ]! r
int ret;, `1 L5 B* ^4 G8 T. M
#if 05 v _! w1 W) t- l1 n6 u
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
7 A3 t5 j3 i" ?, T( c if (ret)
0 f: w* N& l9 q K# q pr_warning("da850_evm_tl_leds_init : User LED mux failed :"* x& x8 H: U* S3 R
"%d\n", ret);, v8 K$ _2 K$ S7 q' I% j
#endif+ D |: c) x6 _$ x# V. ?
ret = platform_device_register(&da850_evm_tl_leds_device);
$ o; @& ~2 |$ g, G+ }0 q if (ret)
2 U, `" x$ M2 v pr_warning("Could not register som GPIO expander LEDS");
0 O. ^* f* m" X( t+ P$ F8 V% ? else* Z) {) h* s% ]+ \
printk(KERN_INFO "LED register sucessful!\n");$ e8 D" T" A" K5 N
$ V- X0 H0 _3 O
return ret;
4 ~. X4 O2 X0 C& {5 X}' h, N5 O9 a( @- I# C0 p
, |, s# }1 `* C; Z4 j# p% wstatic void __exit led_platform_exit(void)2 G! @1 b) _. h F
{$ l) E2 t' Y" ~
platform_device_unregister(&da850_evm_tl_leds_device); a3 H5 d' ~: _! z6 j2 O
* Y A/ G- l2 X, W y printk(KERN_INFO "LED unregister!\n");* T) K% D& o5 M& `" L: _% r3 w
}
1 D7 z9 M- ^; ~ n1 n1 v# n2 S; s& J' l0 I9 m3 g* V; U0 U) \# r
module_init(led_platform_init);% D% h. C4 w# x6 y
module_exit(led_platform_exit);
4 f' D* h& U$ P0 g% a$ U& E: m0 f% _3 R) o
MODULE_DESCRIPTION("Led platform driver");; W' n7 ]) O0 f4 h4 {/ K9 |3 C# L ?
MODULE_AUTHOR("Tronlong");
- j9 B7 o* L' x% uMODULE_LICENSE("GPL");, U# M" ]8 F: T# I* P9 o% r
5 ^0 K& A' u7 P8 b2 x3 E1 _4 _
|
|