|
|
求大神给下面的程序做注解,请稍详细些,谢谢。3 c) r5 K- V1 k1 ^! i9 U* w' M% `
#include <linux/init.h>6 T) H( d0 J$ L" s6 \' \
#include <linux/module.h>
& @/ f% r( S q9 S( ^, k#include <linux/kernel.h>
% k3 _: Y' a0 a#include <linux/types.h>
& e2 N0 J, r0 T! C* l" W7 X#include <linux/gpio.h>4 o& C* K6 j, T9 o7 U/ W- j v
#include <linux/leds.h>, X5 O4 C' I' ]- C& q% y
#include <linux/platform_device.h>, Q t. A, l5 q
E. w e$ }, P4 j/ }" m/ b
#include <asm/mach-types.h>
5 g6 P" m `5 N; [" j/ Q4 I#include <asm/mach/arch.h> ~; T/ R' F4 Q6 x' F, d( g6 n
#include <mach/da8xx.h>
/ M9 U; [: L1 F- ]. G#include <mach/mux.h>
0 p. r- Z5 C& W, m$ \/ s6 ~9 z" `' n8 o' G" [5 ^
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
0 Y# l% K2 S3 W8 I, I#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
2 F$ b$ D- a% C% b#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
# ]0 Y- @. m1 D w4 K7 G. s#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
7 H# x( U2 u5 A) U" N
2 F3 [# T" E. A/ |: d9 X+ `/* assign the tl som board LED-GPIOs*/5 A, ^* E6 C3 s" {; o
static const short da850_evm_tl_user_led_pins[] = {
/ |& o# B4 t( ?# q9 p# T /* These pins are definition at <mach/mux.h> file */
9 b+ Z4 K9 Q4 m& w* E _ DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
' c/ I" O* r$ a -1
0 E% b6 T! U" D( ?};
! f4 T K' W$ Z! f+ [0 ]4 I
$ z% }* X6 C5 w! p7 V5 Tstatic struct gpio_led da850_evm_tl_leds[] = {
8 ^$ _, x V% P/ x. q {
& [4 Q p9 A) d3 P; w3 b .active_low = 0,7 P- u. ?# S8 ^& X( ]: w: ~
.gpio = DA850_USER_LED0,
6 Q# X6 N$ c6 I* J .name = "user_led0",
/ H& B1 o. } D( B .default_trigger = "default-on",
* C$ P% P& o* ? },
# |9 ?0 M" A7 w/ C+ t {
$ u# ^( a W$ s% E9 M+ s q& H .active_low = 0,
+ {% H; Z! W" d" a) a2 a' O .gpio = DA850_USER_LED1,5 F% A' Q1 Z" \- ~
.name = "user_led1",
e7 g6 R! E6 K' z .default_trigger = "default-on",
0 W# s$ G7 R* H1 R7 L! x: X7 P4 ] },
9 C- }/ E1 m6 X$ n# F {: _5 n, T( r; P2 a, u, X0 V
.active_low = 0,. y' \/ i' x4 I1 ?5 q* U$ |
.gpio = DA850_USER_LED2,
. n# O: t- k. |4 y( [1 X' q: c( e; P .name = "user_led2",! t& z0 s8 y2 D) L: u( p
.default_trigger = "default-on",
" s' C0 N; Q n; W },
9 N% x! C6 w" W9 ~: _ {& [* ]1 l( u8 E1 I7 R1 O
.active_low = 0,
+ @3 p" S; R1 U .gpio = DA850_USER_LED3,% V/ l% [# r1 z; Y) T( t- Y
.name = "user_led3",
- |9 G8 W4 G5 i4 A2 i P .default_trigger = "default-on",: y9 n& Z V7 C& F: p
},% w7 R) i* H8 \- I- M! t7 w
};9 J) D6 g" Y) s; M' r! _
2 {# C C6 U# O) n/ _3 d! Y u2 g
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {0 N0 M. _6 G: l! j! Y+ f9 d
.leds = da850_evm_tl_leds,
* U7 A5 U) ~* Z4 ^+ }$ o .num_leds = ARRAY_SIZE(da850_evm_tl_leds),. w) l: W- K* |, f0 O
};2 p/ L \% E* J# C3 k; i- r
% |! D! f7 {( H8 k8 D/ I7 e) nstatic void led_dev_release(struct device *dev)/ w5 R8 z" J' A8 z% C
{
0 ]9 M/ H& `+ R' t! _};
8 r+ U: f: p8 |" ]8 S2 ]
- V/ I; j( `2 s6 _4 nstatic struct platform_device da850_evm_tl_leds_device = {* y9 c+ u/ Y5 W+ i$ K! v
.name = "leds-gpio",
( m- W P. l7 T .id = 1,4 X7 K. [4 d0 g! x7 ~" }6 J2 O# g
.dev = {
& s7 z. F! q% o. ]. g .platform_data = &da850_evm_tl_leds_pdata,8 L2 o5 r/ [! X1 ?& Z6 \
.release = led_dev_release,
* `! V4 u3 ]+ ?& T3 i% [ }
/ c' ]3 [! l& g& G};; ]! B" U0 z+ N0 d; K
2 K; O e* M( @1 {; u
static int __init led_platform_init(void)+ d Z& R1 z$ ]/ g
{, l0 e: b) _4 Z" |! o" \
int ret;9 g- {. M0 @" N6 Z" Y4 C% F
#if 0
8 w$ ^! i8 ~# S ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);9 D9 ^+ `1 o' \4 v3 V* G
if (ret)
; y3 l! H1 F v% M pr_warning("da850_evm_tl_leds_init : User LED mux failed :"2 z2 c1 V; ^; i3 s6 O
"%d\n", ret);( I o [- P3 V
#endif) V# g% t. y6 v& d
ret = platform_device_register(&da850_evm_tl_leds_device);
& U! P, w% [$ X! q- X1 E( w5 E' P9 K if (ret)1 R9 I" m# a x) I3 Z2 L
pr_warning("Could not register som GPIO expander LEDS");
6 c3 l x8 L0 d% q0 \+ u- P7 R! J else, j. z. E& ^, t* w y' I0 P7 f; L
printk(KERN_INFO "LED register sucessful!\n");
: q$ E/ [, B( U* [ {5 t6 a) \# E; A8 w3 Q) }( G
return ret;
- Q$ y) Z$ S0 |9 X: Z/ E. \}6 L4 L8 D7 ^+ l' h) k
: [2 _0 {$ S& w' B4 ]
static void __exit led_platform_exit(void)3 H, j9 w% ~# ?4 N( ]4 [
{, p0 Q4 o. ]7 m' W' a
platform_device_unregister(&da850_evm_tl_leds_device);
8 U7 k) n# d. [1 p8 j% B% Z7 F3 o0 J. ^
printk(KERN_INFO "LED unregister!\n");
' g9 J8 Q4 i9 {) W* _8 E3 e}
- U5 i2 h7 K2 q( m' P1 Y9 I0 h$ \' s( E0 m; ]( `2 ] Q
module_init(led_platform_init);
8 q6 D8 G) Q4 f8 j+ ?module_exit(led_platform_exit);3 j) |* u# P9 q. _! d
& R4 ?3 ]' U. {+ SMODULE_DESCRIPTION("Led platform driver");
8 S( V! V+ B) ~- M0 TMODULE_AUTHOR("Tronlong");
) c9 m3 [1 G! |/ E. t+ q5 k: Y* uMODULE_LICENSE("GPL");/ i; ~: m; H/ |9 M4 z
) D2 b, N; Q" x7 G5 R. A2 c |
|