|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
" h( j/ w) b2 k" M- \8 }#include <linux/init.h>
# J+ T9 Q9 G" ~0 w#include <linux/module.h>
' e/ g9 {# E4 L f#include <linux/kernel.h>; t: b. v+ |1 D8 ?5 ?! M
#include <linux/types.h>+ f- M' u+ B( Y f6 M5 e( e
#include <linux/gpio.h>
}7 Y7 O& @' C) e3 n#include <linux/leds.h>
8 H& G! e3 E# [$ _" n7 [#include <linux/platform_device.h>9 q# z* A8 a- w" |
+ `( k4 u( u6 D4 E3 O" X9 i
#include <asm/mach-types.h>& H9 P# d+ H' Q
#include <asm/mach/arch.h>% o4 X% L: z$ c# f! o
#include <mach/da8xx.h>9 B5 S0 y/ g8 |2 c3 }6 I0 a
#include <mach/mux.h>
/ D' [- i# F5 k; P- J( z( P; H3 ^ {0 D4 j+ {. |
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)0 i* k K% r, c* A( Q" \
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
8 q8 P% X' T" O, @! J( d#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
; w5 G2 g6 J7 p" e5 |5 j9 k) b#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
: |5 ^' O3 J+ Z+ `/ s2 Y5 h6 f( [% w4 l, r4 H1 C6 R% S4 t5 n
/* assign the tl som board LED-GPIOs*/; M) s* g& Z+ J3 n
static const short da850_evm_tl_user_led_pins[] = {
0 \3 Z3 ]/ p5 H /* These pins are definition at <mach/mux.h> file */
* L; `/ K$ `7 Y9 Q$ e DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
+ Y4 |* s7 W% [! B4 {' a% F -1
{% {: ?7 U. P};0 B1 R- c6 B$ _) g) L' h+ j
- _! i- V. G7 H$ [/ Z$ z/ Ustatic struct gpio_led da850_evm_tl_leds[] = {
( Z# Y" g7 X- I {
# c7 j$ q2 T0 P4 J3 M! k .active_low = 0,
" A4 g& C* r, M/ \5 z8 _* X8 W .gpio = DA850_USER_LED0,
6 B, }4 ^1 i4 k* x v0 q$ h4 Z .name = "user_led0",
1 ]2 `2 h! Z$ C R6 D$ W .default_trigger = "default-on",7 \$ F5 A6 r* D
},
; j" P8 S5 c) E* D4 B {) l- \4 p1 ~/ r7 \1 b' A& R
.active_low = 0,6 A0 d! C- f. i! W- d
.gpio = DA850_USER_LED1,9 o* C! J5 T6 r, Z3 s4 C* H8 U
.name = "user_led1",
2 n1 |% T7 H+ e# p9 u' y .default_trigger = "default-on",
0 |% g( a6 k( t },
9 W1 c/ O' s* l+ N {
+ c' [( A% d0 F5 G" U/ U e+ q& W .active_low = 0,
; F i; O0 _- s) j% D .gpio = DA850_USER_LED2,
8 w+ I. A2 Q3 ?& r" ^ .name = "user_led2",
0 W2 _8 s8 [* L, A: N .default_trigger = "default-on",
+ g2 }( K; y) \2 G/ s },% ^' E6 {7 X6 X( x7 i- ^4 o% G7 C' |
{
/ H% n8 f* O, o .active_low = 0,
% C4 C( ^8 O/ G. K7 O( _- P' \ .gpio = DA850_USER_LED3,: F+ F8 z1 `5 @0 S( I
.name = "user_led3",9 }' T2 W/ x7 J2 p" u7 w- \0 B2 B8 r
.default_trigger = "default-on", q* Y) R+ n& k6 H9 l& H
},/ x! u0 s6 V5 M6 Y4 y* D
};
8 B) W( V; I/ I
5 g- M C; k8 }9 x0 X6 ystatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {2 m2 u- ~6 K: V5 h6 P, [& V
.leds = da850_evm_tl_leds,
. M. S# V% ~3 N* X .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
* F3 Q1 c) t5 U& E; F2 r `1 \};
( A$ |2 Q$ c7 W3 a, `
9 R+ h# ^5 \5 @2 Rstatic void led_dev_release(struct device *dev)! |% } |; z$ J3 a% R; a
{
5 U) c* G' Q& h2 X) }/ M" f& u- q};
9 b; F1 B0 N0 t$ s" r; V; c% R" y+ n8 c5 r8 V0 v
static struct platform_device da850_evm_tl_leds_device = {6 h/ e' O U0 c# Q0 b
.name = "leds-gpio",
' |8 v- k/ x, K* X6 k .id = 1,
" N1 G! f5 M/ T. [, r .dev = {
& o. v k7 [- b% B' _* C; ~ .platform_data = &da850_evm_tl_leds_pdata,
/ k6 Q$ _3 Y* p: y' C5 Z .release = led_dev_release," W* ]! v( w) n
}
1 V$ m- @ O6 T' ]. |% {! c& |% U};
) C' |6 d# @6 g. z3 e3 W- E/ {0 I6 v" G4 ^4 `3 m; n* l
static int __init led_platform_init(void)( j0 g/ ~4 k3 }5 c' \. [
{) N+ _6 J. W& f4 F6 [
int ret;
1 `% Q. N# a* s- e# S8 N8 u#if 0; r6 T& K- _7 Z) h2 H1 \5 b
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins); `0 [5 t+ m! W: A6 v# j
if (ret)
2 N/ R# Q" A1 q: E pr_warning("da850_evm_tl_leds_init : User LED mux failed :"* f+ |4 M8 ? f+ ~) j5 w5 X
"%d\n", ret);; X* e) Z5 J0 k) t8 M: d
#endif
6 L+ s& q, D$ v( f2 m: V# m2 s- W6 L ret = platform_device_register(&da850_evm_tl_leds_device);
" @. c$ ]' c3 }- `0 ` if (ret)
+ X/ q, `! H1 v( {- L$ {3 G pr_warning("Could not register som GPIO expander LEDS"); d p8 r2 R0 [- c! I9 ^2 [" ?
else+ e+ v+ ]" P4 {/ K% z
printk(KERN_INFO "LED register sucessful!\n");) e8 F' X0 E: r9 F7 O
5 p5 C$ \7 L0 {6 R9 b
return ret;
7 u4 [3 f8 j9 B3 n8 x% R}) }5 } ^* }) M; P
- l; X0 Q2 Q% x4 n( E8 T
static void __exit led_platform_exit(void)
. Z7 s Z, t4 T7 U: L{
! ^0 n8 m0 [* H% }) {4 j% D! I platform_device_unregister(&da850_evm_tl_leds_device);& B* t9 g" @2 M1 L' ]- p
/ j/ M! o( ] h
printk(KERN_INFO "LED unregister!\n");) }" t9 P1 h3 L
}
- M6 v! q: w5 V+ E
/ D8 v* A4 M2 [( Bmodule_init(led_platform_init);; @5 H3 E* t [2 E" x( E% ^
module_exit(led_platform_exit);/ C, V0 a. d2 {' ?$ G
" P3 f: c6 ^! q1 e% L9 L7 HMODULE_DESCRIPTION("Led platform driver");
6 X4 p) ^" _- \8 ~2 w$ MMODULE_AUTHOR("Tronlong");- q5 `0 \- A" S8 @* E
MODULE_LICENSE("GPL");
: `' F$ p L8 t4 g) _- `7 ~4 G1 P
2 S9 N T# X8 \+ s2 J |
|