|
|
求大神给下面的程序做注解,请稍详细些,谢谢。# G b1 [& U! i. j% x# U
#include <linux/init.h>
' N7 _" \ F# T0 k, R#include <linux/module.h>
7 ?1 o4 X1 b4 t9 h# `) G#include <linux/kernel.h>0 z+ z5 w+ j% B& S- r2 z! v
#include <linux/types.h>
0 ^) V# R% f9 G- Q#include <linux/gpio.h>) s( o( F( S2 `+ M
#include <linux/leds.h>2 Y4 N5 V- `. ]# W8 ?
#include <linux/platform_device.h>! m! p: v) z7 E* E) g# a' o
0 X, a) O5 _9 E2 i1 K. k$ a* ` d#include <asm/mach-types.h>4 D4 X; [( b& T9 Z& Z
#include <asm/mach/arch.h>
* H2 S( m7 @6 m K1 U4 E; Y#include <mach/da8xx.h>3 B4 }2 Q* L1 M' |: b5 n
#include <mach/mux.h>
, c1 Q- D! A" `' y& W$ Z7 C3 E! H8 D, y7 e% T
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
7 S' y+ ^2 b' E0 K2 C. J8 O#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)6 \0 y5 i( e1 G6 m2 ~( w
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
/ o2 A" S% H" B4 ?( {% L#define DA850_USER_LED3 GPIO_TO_PIN(0, 2), g c0 j) E7 u8 R; E, l
: D- y6 y4 Y$ G" O- ]/ E; K2 d( s/* assign the tl som board LED-GPIOs*/
( A# T! V* V5 g3 _0 cstatic const short da850_evm_tl_user_led_pins[] = {) o3 u& s! a4 v5 I( {! S" O
/* These pins are definition at <mach/mux.h> file */
- N x: ?9 Z8 |0 Y DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,. m* S9 ?0 B# a# W4 L) Q
-1+ j6 _0 ~9 @8 L8 ^, [0 j
};& R g" A( A. l& j) @
1 Q' w! h6 W) Q; U0 Tstatic struct gpio_led da850_evm_tl_leds[] = { v5 |( M8 L9 o! Y; A/ j1 m1 v8 B( R2 E
{! n9 |0 Q3 t( z6 _4 G' A8 w
.active_low = 0,
$ }" M- e i, ?. V4 A% H .gpio = DA850_USER_LED0,% H% h, S$ ]& f# c$ T K3 l% F
.name = "user_led0",* p7 p* e: a" M) s# U1 M4 o4 b
.default_trigger = "default-on",
# y3 I, J$ k. j8 s! r },/ Z; \1 M. _( z/ @
{2 Y& Q( s. X' S6 L9 L. h4 F- X, r
.active_low = 0,
5 j$ w9 J; }7 P, X .gpio = DA850_USER_LED1,
3 E( Q" o4 P* [$ X7 a .name = "user_led1",
. {% ], e* B/ s c+ W .default_trigger = "default-on",
- L+ [& { B4 ^7 l8 C i6 N( a },0 c, a0 M# ^; t! O) d
{; r! W0 P! z+ F6 }5 y, @
.active_low = 0,
. z- ` o; g' J7 x: F .gpio = DA850_USER_LED2,
% l( {. C; R" A8 {: }* D7 r& b2 x .name = "user_led2",
5 b1 b( {4 Z6 Y9 h$ T( y .default_trigger = "default-on",
( D7 X3 G1 w8 ]# U9 Q( V },
& |- a7 h/ U! r' @ {: C" a4 X" @) s5 Y; [
.active_low = 0,9 e7 Y3 k% e( @0 p4 F k/ P
.gpio = DA850_USER_LED3,
9 N. o0 h* L/ w( K3 }; o8 [ .name = "user_led3",% }7 u1 p+ }2 h; Y) u
.default_trigger = "default-on",' b+ y8 Q8 V: l! s& {# z$ l
},& i! k2 H4 l. H# ^: l
};3 }4 F: L4 E- R' i. a& V% T$ h! ~, N
1 g0 @, H) N: vstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
" u' ^% x2 x. p3 S .leds = da850_evm_tl_leds,
8 M/ V" s( ]- L .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
: F7 E0 q# x+ c& J0 }5 W& P};0 h: A7 ~% P5 z
6 G" E& t5 d$ [. `. U" o8 J
static void led_dev_release(struct device *dev)+ B$ X2 G6 z+ n7 D, k* k: K ^
{
8 c+ J6 O( o0 L9 h8 c: }# s};9 V9 `9 \, k* \/ o m) M8 D# e1 w* j
3 f; r8 [ Q- y' xstatic struct platform_device da850_evm_tl_leds_device = {
; D; z- E7 z3 E6 Q: w/ N .name = "leds-gpio",
% A' t& g) n. c8 Q+ D* s2 d .id = 1,9 H: B H" h. ?. [
.dev = {
$ z1 u5 }- h2 B2 t; D% S" S .platform_data = &da850_evm_tl_leds_pdata,
- G/ K3 {" x7 [* \( c% H, o .release = led_dev_release,9 v+ d4 L; H% z( E2 J
}
' ~* j9 n! V: c) X};
& g% L7 j8 f0 u( t- f
9 c3 d% R/ P- ] W) x0 {2 Gstatic int __init led_platform_init(void)$ v9 g( A6 @3 ]( B- B; j
{
% `$ O0 c8 S( y& u% s int ret;
' p3 E: s. Y/ O) g' K#if 0
6 |" }3 U$ c0 n/ J! O' Q7 v! h ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);: V* E4 N( i- m% V- @
if (ret)/ U: t7 r! s7 h# k7 |1 S9 R
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"( x2 Z$ f6 c0 r; G
"%d\n", ret); ^% v- O" p) I: {3 r
#endif
8 N A) w1 n+ }' J9 c3 M ret = platform_device_register(&da850_evm_tl_leds_device);6 d3 D/ p8 u* ^: U
if (ret)
; ^2 |8 _3 h0 I) q" E5 v! r pr_warning("Could not register som GPIO expander LEDS");
+ ^1 F$ Z' M! {) Y else
( {( }* c/ z2 o# N3 `& T# L) R printk(KERN_INFO "LED register sucessful!\n"); V' v) _" B# ]0 o3 e+ u
+ S0 e0 a* \4 ]3 X return ret;
" c0 @) B4 i* L}& `) D- a [ H* f+ V# K$ X
" {# C" B: k* T) J- Q$ V$ Lstatic void __exit led_platform_exit(void)
* [; X: B0 f, K. S W- ]{: s. R4 ~3 u \- H1 `, I
platform_device_unregister(&da850_evm_tl_leds_device);
5 I; g' l; H# _
8 X- W% X9 k. K2 M/ ` printk(KERN_INFO "LED unregister!\n");; l5 Y" T. K, G l5 t* K
}
' O' a- \1 t' [7 R2 I8 o# N0 K8 R5 X; [
module_init(led_platform_init);/ J; \! Z% ~7 @7 g* D) o( B
module_exit(led_platform_exit);6 L" M; f# x/ \
7 x! r6 ~& l3 L6 G0 K8 [
MODULE_DESCRIPTION("Led platform driver");; j8 [% \. D# w' u: S1 A: `
MODULE_AUTHOR("Tronlong");/ e1 p7 f0 ?' D% o& ~3 ^) H y, \
MODULE_LICENSE("GPL");
; }1 G# C) ~3 g; c* K) L( U9 S2 _
- l+ _5 L& S* j& Z$ [ |
|