|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
+ N( ]* b6 S3 B3 J; l#include <linux/init.h>
. H! z n& z1 T- d; R- K0 I( d# G6 Z#include <linux/module.h>
8 R* x- I& J+ o' l+ I3 K; R#include <linux/kernel.h>
- L7 |' R& e& z7 U, }#include <linux/types.h>0 p: g2 ]1 M$ X' [8 R, O2 a
#include <linux/gpio.h>+ S$ m/ w! j4 R. r& ?( W0 \8 E
#include <linux/leds.h>. g- A* Z, B4 S: K3 K$ g( S
#include <linux/platform_device.h>. \4 C* \6 s0 @; v6 W" R0 \$ |5 i
* C% |3 y* j1 ^7 }# E {" ]
#include <asm/mach-types.h>5 \6 ~. e5 f" o6 w3 D
#include <asm/mach/arch.h>3 {+ l) y( s5 U
#include <mach/da8xx.h>
; k. G) T, ~" L7 c#include <mach/mux.h>
5 w7 G4 z: H; O3 [' f) }
2 q2 V8 Z4 r3 E8 b#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)# T+ U2 D8 P" @7 _0 V: V. e$ k
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)6 f8 d! w* d" V J; D" X/ S
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)% V- |4 l) I' s3 s# O4 j5 W) m
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
6 R% ?% n! A! K( ]( H# \- c) Z# e: ?. ~3 P. p
/* assign the tl som board LED-GPIOs*/
% @7 P: b, a+ H% f8 tstatic const short da850_evm_tl_user_led_pins[] = {
: l* s, F% ^) _' N7 T /* These pins are definition at <mach/mux.h> file */
! [, Z: e9 `* M: A DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
9 X- D/ ]+ o5 y+ n4 k# P% u -1
/ b. l% Z1 [9 p};( I! Q2 N4 o4 s; n
$ D' y- I7 V0 x7 {$ Ustatic struct gpio_led da850_evm_tl_leds[] = {: z" c! Q7 q- k+ Y+ p s
{8 P$ x) F8 ?" A' l: C* h
.active_low = 0,% ~0 v- d' T. r
.gpio = DA850_USER_LED0,
3 F `+ `5 k! w) B& t D4 p .name = "user_led0",
6 B! y+ S2 I2 x0 J .default_trigger = "default-on",# W5 X! V) h+ a1 B4 E2 g) Z
},! e( y( }9 D/ C0 ~% l
{
' F Z0 f& G& |0 N9 E .active_low = 0,8 l" I- i6 I3 y3 {
.gpio = DA850_USER_LED1,, P1 B) v X+ k. _6 w. p G
.name = "user_led1",7 |& Z6 Z; t/ \8 \8 a) _( P' `
.default_trigger = "default-on",# ]( [( |$ W6 Z6 \
},
& e3 l! k) C& |1 } k4 s$ t @0 Q {
4 `: K! r2 }6 s( r2 {2 H. B" t6 D .active_low = 0,, t( |$ H9 F, D, k6 L9 U
.gpio = DA850_USER_LED2,% U' I: q* Z6 ?( p& ?, m
.name = "user_led2",
$ l, ]; }4 D' K .default_trigger = "default-on",/ S* r5 v4 o" {% L
},
6 p, N3 e; G+ C& a0 F+ L {- x' \4 ?4 x) z, c* H" \ P
.active_low = 0,
* \& x+ I& L" n& Z ^/ J$ x, S1 \) q .gpio = DA850_USER_LED3,
: s8 l/ n) |* |1 [& ^4 r, j% M .name = "user_led3",- v+ e# |4 Z$ v+ j" K5 |7 T& H
.default_trigger = "default-on",
( b" e$ o7 ?! o; F! o S },
/ `) c" ^, h9 h2 d' X& `};
3 Z" @: S: V3 C4 ?+ j) H7 d. ~: A# `
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
4 m5 ?+ d" u/ L( I% O .leds = da850_evm_tl_leds,9 d, V4 ^9 L' Q( C; B* j
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
1 O; i9 R+ Q/ Z! E9 |( R7 n};
" ]$ ?' v& Q& w- g
9 ]1 z0 f3 o; z5 E" jstatic void led_dev_release(struct device *dev). @ o8 s+ ?4 I& x; x
{
& g4 o/ f X8 {1 i1 w0 Z K};
% r: N% A# b+ y: G, }
! s' T g3 c! Dstatic struct platform_device da850_evm_tl_leds_device = {1 P& ^& S. j) }" \# k/ f- q8 Z
.name = "leds-gpio",
. @' |8 p8 h" f) } .id = 1,
/ d' |7 [' k( Y/ ?* X .dev = {
o, Z) U' d$ g9 d .platform_data = &da850_evm_tl_leds_pdata,
" I* l$ ?" T5 m! e, T3 c$ T .release = led_dev_release,
/ N* N% [2 r8 x8 u' x% v r }
# J4 A( J. _( l5 c; P7 A" ~& E2 d4 `}; X" c: o8 k8 h( D# ]2 i f
/ o: i# H" C* l7 n2 u& I! m
static int __init led_platform_init(void)
: y. ]9 q8 ~& |4 c! ^6 f/ L6 q{
/ B9 u, L2 E7 f) T1 k; P int ret;, U' K# n8 }7 ^6 |
#if 0) H: D1 @* r0 X+ h& v
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
# C1 M x, v: V. X6 D if (ret). Z2 C: }4 c5 K% Z
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
^1 g" C9 L9 w" w "%d\n", ret);
3 n4 T' ?8 _7 P1 v" w0 m#endif9 P0 J8 z( \4 ~- }
ret = platform_device_register(&da850_evm_tl_leds_device);
6 r( Z1 n' Y ` if (ret)
: X# R! _) f' h% V+ A6 z pr_warning("Could not register som GPIO expander LEDS");* E& H+ C# O1 a. ], s/ S
else4 O( w3 C' \- v. z+ H
printk(KERN_INFO "LED register sucessful!\n");
* y M% n. H w6 M0 D5 R& {' F" L( h2 s2 N# K
return ret;
- {' a0 D0 ^* I}5 E/ e L# M3 }5 b6 s! z+ I
* @# }( n/ \: ~' G, dstatic void __exit led_platform_exit(void)
) H8 E/ U; a' `+ l) g+ u% S7 M{' r( ]' F1 m* M$ J
platform_device_unregister(&da850_evm_tl_leds_device);
8 ^) k6 \+ P, r% i! R5 k
$ @0 s6 Z! `2 s& s8 @ printk(KERN_INFO "LED unregister!\n");3 |9 ^1 H, n$ F* E* i
}) ?$ a4 k4 r/ e1 L
) r( Y- \/ @/ _% _. S, \' Xmodule_init(led_platform_init);9 p# B. Z: u) [4 {, o' ~) S
module_exit(led_platform_exit);2 u' ~) Z2 o6 n
# Y9 I0 U3 x; w) k! s4 h
MODULE_DESCRIPTION("Led platform driver");
" ^/ A1 J& [- n% y( [MODULE_AUTHOR("Tronlong");
( i( d. _8 m2 b% S* a3 lMODULE_LICENSE("GPL");3 K6 G6 ^, D& L2 r) g" D k5 F
: y. t3 A/ k+ r/ L
|
|