|
|
求大神给下面的程序做注解,请稍详细些,谢谢。) l: N9 K9 @# H' _+ w, L) F! k; l
#include <linux/init.h>1 l! u$ [9 u6 }' ?9 g: V
#include <linux/module.h>& n! X- `7 U& d
#include <linux/kernel.h>+ f. h$ H4 v# a: o; c, R, x9 S
#include <linux/types.h>2 g1 b% a4 b; ?
#include <linux/gpio.h>4 Y2 z! r# _) s" F% S: c ]
#include <linux/leds.h>$ a: G, h* D# j
#include <linux/platform_device.h>
- x/ r4 G- X5 Q8 n- P2 _* O/ G& I8 Y! E- `2 D5 j& _) t
#include <asm/mach-types.h>2 _+ z% E+ ]2 ?# @% \3 k
#include <asm/mach/arch.h>
+ W' X. G6 n; H0 R7 N% F#include <mach/da8xx.h>
! Z# h: X, l& T/ Z#include <mach/mux.h>- K1 `' W2 I# @" m3 v, ~7 {
* @) f- r7 f- M6 r3 @* O* I9 ]. `: u
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
# L' a5 S) Y- N5 C! J#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)1 f) }# y& O+ ~; W; z
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)4 Z7 v3 w6 s8 R7 x9 C
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
$ W* e6 a+ D* V- w7 f" J- i8 }: @8 _, i3 ^0 F" Q5 c- A8 }3 P7 c& G
/* assign the tl som board LED-GPIOs*/
! ?$ o) d! h8 N, C" i8 Ustatic const short da850_evm_tl_user_led_pins[] = {
- b, P5 |$ p" O( j5 f! j% j /* These pins are definition at <mach/mux.h> file */+ H; h" x6 f& _1 N
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,% x' m% X0 q( C2 G% b2 q+ b
-1
6 H. u$ G3 a4 q5 m' _$ N0 O};/ z( ? V. g7 ~* ~& Q+ ]) A6 V
+ O" k* t0 O9 z+ j2 q. E& Nstatic struct gpio_led da850_evm_tl_leds[] = {/ _( {9 ]9 w/ h* f1 h
{8 _" e$ o8 m0 N
.active_low = 0,. I1 h5 Z' n* y, K" V
.gpio = DA850_USER_LED0,* d- I" C9 |+ u* j7 V
.name = "user_led0",
7 @4 ~$ e" h) h, O; c8 \2 \! P .default_trigger = "default-on",
( X3 V _7 w& d# `, } },
; F( ]( J: [+ S2 x' S1 ]& ^; m {6 J' ?2 ^$ O- f; b$ r$ K
.active_low = 0,
3 ^8 T7 f8 f9 P7 w9 L* n% ?* @ .gpio = DA850_USER_LED1,1 W% A# b( r, {' m2 C q
.name = "user_led1",
) o: |/ @/ t' p5 s .default_trigger = "default-on",
2 @; q5 T9 x7 H" o" l$ b( Y4 L7 I },
" p0 E# i1 ~) M {7 S: a% v5 _$ S; y9 g# u
.active_low = 0,1 K4 w Y1 x+ z3 J1 c8 l- Y+ g
.gpio = DA850_USER_LED2,8 Y! J/ B% j" Q, P" M) P5 E' ?! x
.name = "user_led2",) J) g- S4 Y# D6 ^4 f
.default_trigger = "default-on",
+ E; P5 |% H- { },. _$ h$ B0 t& B* [7 ]
{, g# C/ C P4 h! t% b5 V: J0 R$ I7 Z
.active_low = 0,
9 q* r" O _. z+ x- `3 H7 m( u .gpio = DA850_USER_LED3,
7 X! N0 i+ A3 f1 `) ` .name = "user_led3",8 G# C3 s8 C9 u) d( X2 r8 u, O; R
.default_trigger = "default-on",' k* L/ v+ z+ c- M! D3 k. N3 |
},
. B; g# z1 T _( j) [};
9 g! C" m: [' H) ?( {5 J) d7 U" N5 `
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
5 S" H t* h& u0 x; Y' r .leds = da850_evm_tl_leds,! j% G2 |" L2 `, \
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),+ P9 A& m. H1 U
};
; w0 [8 {! T( x6 X. K9 o) G* y3 ]1 r; g+ d, H! p
static void led_dev_release(struct device *dev)* n4 U: u! j: E4 V: y# p
{
+ X' n3 [$ i- y8 q! F* b0 p5 x! G* i};
* l2 x. l2 ~3 L6 D! Y1 c( e d$ ]
3 w$ x8 ^) o( V: N4 Y# Dstatic struct platform_device da850_evm_tl_leds_device = {
% Z% \& F# C' P Q, z .name = "leds-gpio",
: z, `+ P9 c ~6 d5 K3 N; c .id = 1,
+ v" @. f. ^' Z B( ] .dev = {
( f, K2 n6 W: |! F c' ^, m3 ] .platform_data = &da850_evm_tl_leds_pdata,
: p4 o# S1 q! g; y .release = led_dev_release,
) n& m3 p6 [0 g9 V- U' E8 y }
+ i9 x, l% O! Y};, _+ S [# Z" q
( @( M: v* U- K4 ^static int __init led_platform_init(void)
( f3 K+ y. Z' `2 v' [{" P8 N, U, Q' ^' Q8 n/ s; R; r/ S
int ret;0 o$ ~; d# ]% ] Q' j1 G
#if 0
8 H7 P5 s( L5 i5 {" Y ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
& F: x; z+ U; q3 D' T if (ret)
8 g5 g4 a1 e z+ ^( Y pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
" g5 h1 ?. b5 x "%d\n", ret);
6 k. r1 L3 [) I& b#endif' B$ S; o2 p5 m
ret = platform_device_register(&da850_evm_tl_leds_device);
8 ?, Z0 n; w O7 h if (ret)6 |3 V- t a! O, U {5 X+ m% E# I v7 N
pr_warning("Could not register som GPIO expander LEDS");% P4 x C) h, C% K; T- g9 `
else# p, G2 ~3 a4 i! ] ~; m, Q
printk(KERN_INFO "LED register sucessful!\n");2 M& Q: ]) A! O6 ~
9 h P& M0 V" b
return ret;
; v. D, v: V8 T6 q! M0 p( D}
- x; ~: }0 {5 M2 D
0 D, K- `1 _* m/ o, X, ^6 `static void __exit led_platform_exit(void)5 A# R/ B$ i" C7 Q" k, F; x
{
: M4 r1 S( k9 {9 V' w platform_device_unregister(&da850_evm_tl_leds_device);7 e+ C; M7 x% R- A5 M2 g
" q5 n) b: W4 a( D3 i8 q
printk(KERN_INFO "LED unregister!\n");& L& P' s% I* B0 O |
}% C0 a- v& e. j3 C) z1 h
& G9 J) c+ g# k" q# a, \0 fmodule_init(led_platform_init);
7 ^( b) n0 B, C, t: n! hmodule_exit(led_platform_exit);( x" v" [, ^* X
1 t! {7 }4 q2 y# H. X- M2 @
MODULE_DESCRIPTION("Led platform driver");
) S7 J' j7 B9 S1 K. o$ g7 M, j0 U# ]MODULE_AUTHOR("Tronlong");: y' ~- a4 |: Q" u& Z+ F
MODULE_LICENSE("GPL");
) ~8 V. F+ G5 Y2 [1 c1 p. W/ S) G+ i! Z$ X3 A$ A
|
|