|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
3 J( k' _ V- ~3 g#include <linux/init.h>
1 `3 @( N1 |+ O' }8 g4 T#include <linux/module.h>" J5 ~, c# I' ~7 }& L
#include <linux/kernel.h>; I& G, d2 z$ b d; {
#include <linux/types.h>6 ~; a/ v o1 F+ n, ^
#include <linux/gpio.h>+ [+ Q5 W# k7 L* Q* c
#include <linux/leds.h>9 E& s5 X# Z- {
#include <linux/platform_device.h>
# g+ C2 |% b# e" s% p
9 k& d0 y" g- }8 T8 k#include <asm/mach-types.h>; [# R. e6 Z# O- B7 Z0 ] _
#include <asm/mach/arch.h>
" \2 K5 t% p' ^4 H9 @" U9 _$ O: u#include <mach/da8xx.h>
/ \2 N9 x& \+ F* T7 L1 _: `% A#include <mach/mux.h>5 k# L3 G4 x5 L& u1 \0 t. ~' V
* Y6 x$ l5 ]( e0 j
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)1 ^! F, r4 u( g0 X2 z/ w: v
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)0 E1 v2 w9 h0 p7 R9 S A2 _& F- m
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)7 u U$ W" J# s+ M% Z
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
( a2 Z. i: \" v' c$ T
5 ]0 Q# U: h/ m/* assign the tl som board LED-GPIOs*/
1 F, a3 G7 D& a. Nstatic const short da850_evm_tl_user_led_pins[] = {- a* X4 C T; C4 c' e# {0 v/ O
/* These pins are definition at <mach/mux.h> file */
0 W& d/ x# u: z: U, {; C w DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
% R2 n1 N5 o) _ -1
* f d0 }9 \' M+ f( b3 \+ o};
2 O* ?/ _" Z {/ y
0 t% D( F6 ?: p+ J5 Sstatic struct gpio_led da850_evm_tl_leds[] = {$ p7 u5 ?, g: t
{4 r& G8 W3 L- x+ V5 P! L$ X1 m* Q
.active_low = 0,+ D6 Q( W8 \9 b/ i# E( F4 e H. B
.gpio = DA850_USER_LED0,6 d9 _( d4 I. \
.name = "user_led0",
* P+ s/ P" ^5 z4 m+ I. [! W1 M .default_trigger = "default-on",
9 M5 P6 }+ Z( S) V" C4 \' V },1 {' h* }' W+ X$ y
{4 k& b2 g3 i% Z9 V6 M) U7 O
.active_low = 0,
* {# o) [ |- y8 _# ?1 [ .gpio = DA850_USER_LED1,( ^$ I4 |+ @% v$ R+ @$ S
.name = "user_led1",8 } ~2 o. F. ~" K2 ^$ E; @
.default_trigger = "default-on",
6 t4 V' f2 d* `* b+ i+ p5 g9 Q },
0 a: k, C5 |5 O/ B3 Q, F {
+ n; s. `: I& K .active_low = 0,
1 s' G+ j9 ?, s2 q m .gpio = DA850_USER_LED2,2 _% j+ p" Q9 R4 @4 W2 V+ X: g
.name = "user_led2",8 s4 E1 r) f1 O& q
.default_trigger = "default-on",4 J1 [3 e8 e8 _. u) ]6 ~; a2 \
},
# c; k) n6 a. p {9 ^- E. d1 h+ l/ O! s
.active_low = 0,' I9 T* ?+ ~( t
.gpio = DA850_USER_LED3,
, ]) Q3 x2 P4 ~: q .name = "user_led3",
: D- _: X6 P9 w h3 E# N .default_trigger = "default-on",
# t" g% f& c3 G, w },3 u: A3 o: F+ f& r) _/ ?% Y) b
};) C3 ]: g! P6 z5 M0 s) i/ h3 L' Z
$ x. ?; D+ V' k4 U; [! Z2 s
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
- U5 D" z. m/ A' |: S/ S! c' _ .leds = da850_evm_tl_leds,
6 A. v8 K' B5 _4 { .num_leds = ARRAY_SIZE(da850_evm_tl_leds),/ U& q( w9 [8 ]4 ~" e
};
. ]' O- T9 n! H$ a1 W
' v+ }2 p7 B5 z8 X9 lstatic void led_dev_release(struct device *dev)
" Q6 s5 d9 v, h; n{# A) X$ R6 e+ y" o
};
. {8 \( Z) L5 i* N& p( A& Q) @" Z* T1 K# L' H+ f
static struct platform_device da850_evm_tl_leds_device = {
4 u# ~& x A P' V .name = "leds-gpio",
& I; Z# p; V+ w% H/ d .id = 1,
, x3 |. i7 Q6 W$ l: i H .dev = {
5 L8 c7 c: V! s0 r" T2 ?' R+ E .platform_data = &da850_evm_tl_leds_pdata,5 S7 @7 u% @. B0 {9 u
.release = led_dev_release,2 { v+ i: K* z. j0 z2 b( b
}
: g) x2 f6 t4 K& ?% [8 L7 k};% ^: k% [4 J+ W* a, k3 ^, F
9 G, T9 X9 E( _$ V1 C
static int __init led_platform_init(void)
0 z0 Y2 K2 _, Q6 h3 P{) ^9 |: f& ^& J. u
int ret;( W) {) z$ a% `% P! d6 E
#if 08 b/ Z) J4 H' [, e% |
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
$ Q1 ?3 k& h1 \, F ~1 f/ g if (ret). x. M5 X9 t2 x! \$ i- p$ l4 @
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"4 P1 Z3 g) R, k5 q% ~2 q! @! v
"%d\n", ret);
$ O3 [; K: d+ \#endif7 A- c8 p2 w2 q# O+ d( R P& g
ret = platform_device_register(&da850_evm_tl_leds_device);* K8 N7 o0 N1 B8 ?, l, J, w+ A
if (ret)
9 s7 t1 ~ @2 r; r+ Y$ c r9 q pr_warning("Could not register som GPIO expander LEDS");( T+ W, }4 ^( p% O; E
else# o2 T K- |/ h3 H3 R$ l
printk(KERN_INFO "LED register sucessful!\n");$ J/ m$ F9 Z5 _ h2 v* ~, \% F
9 V9 H% b, [$ A8 h2 ~3 V
return ret;
. \$ @! E6 Q7 i, O# c M}. X+ R( U3 i% e- L) ^' C2 R: h
* z5 v! O( g7 k; q. S; F+ Nstatic void __exit led_platform_exit(void)
6 F" F; c' t4 b: P/ }{
+ e$ T3 a; {* a" i- K' Q0 c$ z platform_device_unregister(&da850_evm_tl_leds_device);' n! |3 R# h5 i% ?" P! ~. T/ b
6 H0 n; n, S% \8 Q0 X0 m1 v5 \9 _ printk(KERN_INFO "LED unregister!\n");
5 s3 I/ O3 b7 i% x, i1 H, \0 n}
; I7 z3 i8 J. M P! c; H+ q" p2 v% z$ u& S/ m9 [' d! Z3 v
module_init(led_platform_init);+ j4 i. O* M3 e+ C
module_exit(led_platform_exit);: |9 a S' Q4 B) c: o: Q$ M
7 N7 P$ e' w2 \: ^# K9 R- hMODULE_DESCRIPTION("Led platform driver");% g- l& d/ ]- u3 L6 [! c4 k
MODULE_AUTHOR("Tronlong");( W6 O# B* {+ L1 H' h& m
MODULE_LICENSE("GPL");
/ M* s# n* l, x* u! q# h# F: X
; V3 C% B; p4 n0 a' i3 w8 G |
|