|
|
求大神给下面的程序做注解,请稍详细些,谢谢。( O$ B+ _9 `6 P' N) y: J3 b/ B
#include <linux/init.h>
; [9 ]# G9 G6 `! F#include <linux/module.h>
/ n. e1 y+ e: C6 u2 l, G7 }; V#include <linux/kernel.h>& o6 F8 x, i& n2 ~: b* l
#include <linux/types.h>
! d. u% D6 Y$ A, P- K#include <linux/gpio.h>* D o* Y" h4 o' Y
#include <linux/leds.h>
4 l1 ^1 s$ {1 k1 e/ Y( W#include <linux/platform_device.h>
+ m8 X: p+ R$ l6 [! E, b" k2 K2 q# y
#include <asm/mach-types.h>$ G/ N7 y0 @# E3 X3 U& e# h0 `
#include <asm/mach/arch.h>! W! c, Y' S1 k' z$ `' t. I
#include <mach/da8xx.h>
; W) ? q) N* c b. t#include <mach/mux.h>) s; f7 ]& I) F/ F( f$ L0 w6 V
7 v0 O4 U9 H* C) U6 ?% Z" x+ }
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)' s# e! h3 x+ W% y8 F, y
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)3 t- w% ? }7 E- d3 [ W" N$ m* f
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
0 Z; T) y" N+ Q, \#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)% _) ^- A" q, g* z2 p3 \
3 v( d$ E2 t- N& e/* assign the tl som board LED-GPIOs*/
9 c3 \ {6 ^( r- e7 {& _8 ~static const short da850_evm_tl_user_led_pins[] = {
. r* o! }# Z2 t5 A1 ^ /* These pins are definition at <mach/mux.h> file */. c( _7 L; |) D; |7 P; A$ [
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
: A' F& r' X' l! W( [& O, b$ q -1
* ^' q. ^8 Z$ Q};& P. _. T Y& g$ m
9 Y( t& h( _3 C* A$ }1 |/ W7 y
static struct gpio_led da850_evm_tl_leds[] = {" }$ P* n: y9 U' T* F' n- e
{
+ ?! ~7 `5 n& @9 `- y .active_low = 0,) j/ V! R7 r; @, \% w, E4 f
.gpio = DA850_USER_LED0,
0 |, r1 T$ m/ f$ A4 B; _. m .name = "user_led0",
! @' K$ d6 l& ]! K2 v# o& ]; x7 ~2 { .default_trigger = "default-on",
1 |9 o; { f; W5 Y5 A4 E- `2 f },
* W& b: ?$ f$ W/ {. D {
$ ^* L, A* a8 `! X# K1 ~: p# T0 X .active_low = 0,1 E8 B! t+ W! w; _+ o. s1 ]
.gpio = DA850_USER_LED1,4 L: g3 B9 _3 o. }- w1 {
.name = "user_led1",
& s7 [' p3 T) p' a+ @# a. _' H .default_trigger = "default-on",
) E" [. B3 l, x- m$ U },+ C' u" n5 r! y m. @! {' ~- B* W* G
{
1 x6 b! Q7 Y0 o$ N' ^ .active_low = 0,
+ ]. [; V& L9 T* G0 | .gpio = DA850_USER_LED2,
& m, y" q" x+ l) Y .name = "user_led2",
: J) G9 U8 I, [! g" G .default_trigger = "default-on",) G% u3 K% a& V8 C. ]* V u9 y
},. P4 e* T" L0 Q" t/ w
{
! d$ Y9 c8 w9 D9 X# @$ i .active_low = 0,* W% l. f. y0 |$ s! ]
.gpio = DA850_USER_LED3,- P- G. P8 b: |$ J+ ~
.name = "user_led3"," U& U: y4 J( t2 N# Y+ {
.default_trigger = "default-on",
3 y' Z% \5 U( R1 G },
' Z' J. G$ u- j: P/ ]8 b2 U};) i& ?* V D6 N) c6 n" y) ^9 y! h; ]
- Z8 M' B/ J6 y. {7 qstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
7 A$ x3 _$ H3 P .leds = da850_evm_tl_leds,4 H$ W0 I# @8 h9 `" H- h
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),! x3 y: S9 L5 } m" c" u
};
* ]9 f( A/ o4 S1 C \& s
$ e: c, P0 [! }2 w# ~3 ?2 Jstatic void led_dev_release(struct device *dev)
7 U3 Z. P. L6 z1 b5 Q& \{( a# L$ P3 _2 T% |0 }3 N( t5 }
};
9 o$ r, m9 {- c% o% t7 _. C5 j1 m- c
static struct platform_device da850_evm_tl_leds_device = {; }( t6 _4 F4 I; v' \% o6 y) ^, }
.name = "leds-gpio",- K, d% l9 j6 D6 H! d
.id = 1, j4 |$ [5 O! R' {# `
.dev = {
$ r5 ]; ~: R5 K; c .platform_data = &da850_evm_tl_leds_pdata,
8 L. X3 F, l6 T( R _, Z .release = led_dev_release,
' H# ^ V2 q* v: U# o/ @ }
* M0 s( _! E, f5 Z( A/ v: f* P1 R: u};
9 H. v; Q8 \3 w) t2 N2 U7 v/ n, _/ A& |+ R% H" u8 f4 }) I6 x
static int __init led_platform_init(void)
0 B2 r* F+ \8 W, a% I{$ E) c* H N, o5 y
int ret;- e6 ^' g- c4 K/ |
#if 0( ]: W" ~) x, I( H/ v9 B' c% `
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);8 M/ f8 z' B0 v$ r* A' P4 \
if (ret): g1 U% s" h- t+ p5 E i- X+ u$ B
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"# E* ?5 \1 _5 l6 s: I
"%d\n", ret);
: C1 ?7 _' R$ i8 L) \- Y( \0 M#endif) F( e% T% n l# R+ B
ret = platform_device_register(&da850_evm_tl_leds_device);
, ~9 c! L* @- L if (ret)
0 r1 ?# a* U; F+ X' C* Z$ w pr_warning("Could not register som GPIO expander LEDS");2 P9 e# p; Z. u& D% Z9 C8 J
else
) P% r1 z' z8 D3 p, B+ x printk(KERN_INFO "LED register sucessful!\n");
' z& B+ W, ]$ I3 C; r+ k
6 f" |% L4 j: i9 R' @0 c3 }6 t return ret;
4 \5 z( g" D8 M4 d1 M# M}! r3 X0 L. ~: N% z4 ?8 p* a: X
+ e, A2 y# R8 V1 ~7 F$ {static void __exit led_platform_exit(void)
% h) A# w! H' j! l5 _7 L, T0 F/ A{2 F6 U3 n' C: M# w
platform_device_unregister(&da850_evm_tl_leds_device);2 t( P" U7 A$ l3 e- ^, n T
" Y" U8 S: \; U' A- J) G# J" j& W printk(KERN_INFO "LED unregister!\n");
' M! c; C+ a: ^* H! D) Z}$ H( X- o! I) \; ?: U$ m2 G
1 w9 L0 y0 ^9 X, X# I8 H* I$ pmodule_init(led_platform_init);
, X. Z2 [7 E1 n7 _/ [7 a' Pmodule_exit(led_platform_exit);" L% d, ~4 a" q# L2 A, h
3 Q5 w1 ]4 u3 M' W
MODULE_DESCRIPTION("Led platform driver");% u% L: ^/ p; k& @; h$ I: r4 q
MODULE_AUTHOR("Tronlong");$ Q _2 J6 ]) C2 b
MODULE_LICENSE("GPL"); C( A" I9 S! b- R: m# l+ |4 w
# c& r8 j0 T/ G( I, o6 x |
|