|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
- O/ `9 C* v9 C7 T% f6 x$ p! b#include <linux/init.h>
8 M( O9 \( {% Y! K# \+ Z7 ?#include <linux/module.h>3 ~. Y8 T u/ i* h# }9 w+ p8 y$ a
#include <linux/kernel.h>
- R5 f" Y9 H; M* }1 s" D#include <linux/types.h>
3 n# {* e; x4 M6 E3 m/ ?#include <linux/gpio.h>
7 V) x" p7 Y( }5 {& } S#include <linux/leds.h>
7 |( d8 K" p8 K! v7 ]$ j#include <linux/platform_device.h>" b3 ~$ w: x: G6 R i
% Q0 v- p* u/ K/ e7 G#include <asm/mach-types.h>$ K2 x G( `- I! U) Z" I' C
#include <asm/mach/arch.h>
B# f( ] q- r4 h5 J- \7 k$ ?#include <mach/da8xx.h>
% G' j" r1 S- F' L* |#include <mach/mux.h> H* a6 w8 e( w
1 B% w$ D5 a( p6 o) d#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
; ?8 c* ]: d+ E1 I. ^! \( E$ r#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)9 s- }' l3 P$ Z0 G; u1 y, P
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
: a0 q. @, P- H+ I#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
+ H, D7 @- e" j8 `$ L: {! J9 x6 B% ]! H/ {5 D9 J
/* assign the tl som board LED-GPIOs*/
% ? v9 U; {5 w3 Y7 m' Ustatic const short da850_evm_tl_user_led_pins[] = {
4 j) r! H1 x. d h6 M$ [, E /* These pins are definition at <mach/mux.h> file */& H/ e/ G+ V4 M% _
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
. v# ?: w2 {* w5 p) f: Y6 _ -1
3 G C2 K" Z2 }' J) s$ ?! _};
r; N" B$ E! ^$ y2 f* C3 i) y
4 n* ]/ S) j/ D( z% N: Ostatic struct gpio_led da850_evm_tl_leds[] = {
* m* d% y/ g: ~ a {) U- w, M0 H8 p) x% l9 c
.active_low = 0, t3 k* j8 V. E( e# E
.gpio = DA850_USER_LED0,) h, {9 H, s; m
.name = "user_led0",9 l* z: _4 t. A4 L& B
.default_trigger = "default-on",7 W) I9 c4 K2 i" O! o4 C
},
% {" Q4 I2 x+ a/ E7 U- S ] {$ t6 Z/ |5 n: f M
.active_low = 0,
: ]6 o8 l8 b7 v) m3 C) L .gpio = DA850_USER_LED1,6 h! |) a/ `9 I" a2 X# y! ]
.name = "user_led1",; W, q/ o. C: u: e6 @9 j
.default_trigger = "default-on",
; G) _5 [' ], b K% B0 I- l },* T9 h$ x c F* `7 t5 M
{
2 o1 m! \/ i% H0 K .active_low = 0,
) y U c0 F7 s) J1 }5 q' n .gpio = DA850_USER_LED2,
4 S. B& r# c( b I1 w% n .name = "user_led2",# d( R/ a/ R& t5 d) a
.default_trigger = "default-on",
- G! U; j) @* @/ W },% y/ w- V4 o' n; h* U# n% Y* j
{1 ^3 e" x6 R# Q7 Z+ q
.active_low = 0,
, h' p. ?: e+ q% ^) F; O# N) l6 | .gpio = DA850_USER_LED3,. a' F5 c6 t4 P t0 s8 r
.name = "user_led3",
" L. P4 c% }6 x% P( u .default_trigger = "default-on",
2 j# Z% ?' x1 K },
" q3 F' l+ \* c' d6 w l. z* c$ k+ h};7 X7 u6 {: P: Q0 D, ~
5 h- w8 M |- }4 Fstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
, k7 U, `8 u& T$ K/ ~& ~' j r& R .leds = da850_evm_tl_leds,7 t4 B0 I& x3 v, x0 S/ F: I
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),, a. |. a" u# @6 d, y) _. R4 V
};8 r$ M6 E$ z m- t( G5 k) k
7 M+ s$ R7 n8 f' ?7 [0 v- [static void led_dev_release(struct device *dev)1 J" v$ z; K; \
{
7 x9 q0 l2 D! ]0 J8 N};
3 _0 w* P7 x1 V5 B% ]+ d1 p+ @2 D9 U. E4 n
static struct platform_device da850_evm_tl_leds_device = {
( d, G% L) p, p$ g .name = "leds-gpio",
3 w: x! s+ y z$ c# i .id = 1,# ?. M" I3 m# r- x) p8 i
.dev = {5 d6 t w' |: y' t/ n2 r$ [
.platform_data = &da850_evm_tl_leds_pdata,
9 z2 o' y6 |. J) s8 b- i* F .release = led_dev_release,0 v0 ]6 O6 X0 u- t' ?2 @
}$ |3 w3 m: X( m( m* U; Z, A I
};' g. r+ h9 c0 w* o6 e
+ E$ |+ C H0 m% c( h* Estatic int __init led_platform_init(void)
; X) V7 X4 b' h. I. Y* E) M) _' k i- s{. n) r: E0 q$ @ |# R: a
int ret;% p Y ]; j. J, m& y- ~& p
#if 04 z, ~4 R' v! r3 E" L4 V' T8 m
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
7 l% v5 y& a& j0 A1 `: Q* y if (ret)
6 l2 Z, {5 v2 i3 x. D. d% p; E f' U pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
# _4 T/ K0 q8 q% m" s "%d\n", ret);8 \$ {; ?! Z4 H8 \3 q4 D+ z& c
#endif
" h7 W0 T- Y3 u2 `0 Z. V+ L ret = platform_device_register(&da850_evm_tl_leds_device);
. C" Q6 @ s! Z3 p# b9 f/ z9 V if (ret)
4 I. @* S+ _' m' D$ p: J pr_warning("Could not register som GPIO expander LEDS");9 B5 K2 R, _! R( B; d
else
$ t# \4 I. H- T s; m' R# d printk(KERN_INFO "LED register sucessful!\n");! c( Q$ z+ Q& k: q5 y' w
$ Z* C, T& y% |8 {. J& y: A return ret;
+ \& D: G0 \9 t2 G0 K) N}
4 y' c6 W3 l& i1 g# d
* d% w+ l2 @0 ~. m) o9 B! W( @static void __exit led_platform_exit(void); o. `% b2 X& b D' c
{
( w/ ?7 |: r b k platform_device_unregister(&da850_evm_tl_leds_device);9 P; m" R" d) ^" x1 ]8 `' w9 p
1 \4 ?; J% `" s printk(KERN_INFO "LED unregister!\n");! j* b* U& t* \* k) k0 U
}% P( s0 i7 g9 q7 C% w
! y" K: e) X6 O1 S! [module_init(led_platform_init);
- x: E: K: t* `' e: s( Ymodule_exit(led_platform_exit);4 \4 D4 |2 X. T! M' @ h
4 ?% _$ Y" V, ^: s: G# U. O
MODULE_DESCRIPTION("Led platform driver");
& U& O* N L% O! S% c3 O+ {/ WMODULE_AUTHOR("Tronlong");
0 X7 W, ]5 S2 w3 cMODULE_LICENSE("GPL");" o9 d8 G% C/ o; e
2 Z q. m+ D+ X+ l |
|