|
|
求大神给下面的程序做注解,请稍详细些,谢谢。9 b& W+ Y3 q! ~5 p2 f6 j
#include <linux/init.h>7 m n3 E$ Z0 L- x" I2 ^; |
#include <linux/module.h>' `0 w2 t* k2 A# E# l* x* l
#include <linux/kernel.h>, w2 C& X' T* R5 e' O3 [/ N
#include <linux/types.h>
2 [. E/ x; O3 v- v2 M8 V# o- G: \1 K1 C: t#include <linux/gpio.h>) H( V$ f; Z4 Z( c$ p
#include <linux/leds.h>
9 W/ u* }. G1 g% ?1 U+ |#include <linux/platform_device.h>
2 J. w- v, w3 y/ s" o8 Y/ E( ~2 |, x" M8 M! u
#include <asm/mach-types.h>4 ^% A$ x( \3 ?) }9 u/ i
#include <asm/mach/arch.h>
, p/ j7 y% H( Y3 k#include <mach/da8xx.h>
1 r" b, m) T1 Q4 O" ^) U) |$ X$ }, o#include <mach/mux.h>0 c. t/ @9 o% A/ p$ z
' G( N4 A3 f I8 _, W
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
' U# c& N: d0 \! A0 D k& f. ~; Y+ s* A#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)$ D( I* H$ q8 @
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
8 k: b) m% F( ]* J& s#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)+ ^4 F& T b; \) P6 K5 q
@7 C' K( z' C6 P9 P
/* assign the tl som board LED-GPIOs*/8 Z! s) {6 B7 S3 M0 n# v
static const short da850_evm_tl_user_led_pins[] = {2 O" r' _+ } [
/* These pins are definition at <mach/mux.h> file */* Q F8 h* |4 \
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,6 s$ A# L- O3 K' |2 L
-1
4 {. ^7 p& j- R1 \# x8 L% T0 p};: l! Q7 ?. i! n5 L, _
- {0 F$ p k* }7 y. E h
static struct gpio_led da850_evm_tl_leds[] = {' Q5 a) `/ z4 l- y6 F4 N k. C$ W
{6 D% c' `$ @) g. w
.active_low = 0,
1 K) b3 z( B3 w3 \ .gpio = DA850_USER_LED0,
# \0 e; n' P% |, B( f+ J .name = "user_led0",
6 c% p) e/ i# S .default_trigger = "default-on",6 `9 Y$ t8 U1 O, m
},
+ t: j" K" T0 o3 t- |* o8 l {; J+ u: `4 S: V, `2 A
.active_low = 0,
) Q& E8 N* `( n; y .gpio = DA850_USER_LED1,
9 [( Z. P, ^1 l( S .name = "user_led1",
. ~7 f. _4 _3 C. a* u .default_trigger = "default-on",7 ]1 v( ?7 M1 }
},! }1 u f: K/ q0 P/ \
{
' l: C% K3 o% C4 d* A, J .active_low = 0,
) m( w; c1 Y( K; Y& p .gpio = DA850_USER_LED2,% g6 J# K/ V. X
.name = "user_led2",
% @; z' \3 ~& \- c. I .default_trigger = "default-on",' |1 }; u1 \5 U- q+ {! b9 t
},
2 f" q; a) L Z: B& ^ {8 a8 G% ?; P1 L# O7 \! L7 q' M
.active_low = 0,
- X8 J3 I! H& n: v2 r" w .gpio = DA850_USER_LED3,% [4 l' E* J6 J: \" D
.name = "user_led3",0 q! |. q0 F$ U5 |$ H. U
.default_trigger = "default-on",
5 M. c% o! ]; @3 n8 d, J- L0 j! H },
0 H' `8 _: x6 q2 K$ _5 ?};8 p/ f7 e% w$ k8 }4 k$ e# M
1 g- O N. X) f9 C4 k9 ]$ L7 R
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
1 u: O5 w3 ~ `6 z* x .leds = da850_evm_tl_leds,
& Z: v) m+ |4 z ?) Y; S9 m" M .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
6 T5 R5 g: \6 S% V% Y2 @};5 A+ P" Q( { Y/ Z* D/ v+ l q
6 o# q% B; B7 q9 P* Bstatic void led_dev_release(struct device *dev)& e/ t: b) b, ?, p) p9 u
{# ^7 J" o* V/ q' l6 {
};
- {; r5 L( n: E! G4 q4 [
: P/ v6 W) Y$ A4 ^static struct platform_device da850_evm_tl_leds_device = {' q5 K/ t3 E* n2 M
.name = "leds-gpio",: L1 d9 w# h0 o0 b2 o& H
.id = 1,* p7 {% C7 J, \
.dev = {
/ ^2 e( T, N2 R3 c4 u .platform_data = &da850_evm_tl_leds_pdata,9 k! A6 L$ u* H& g7 c
.release = led_dev_release,( b8 s0 J u( {
}
1 z& M' O$ ^: D};
# F1 k! L4 s# @) c+ V
: K h- N+ [! {1 w1 `" e6 v0 Bstatic int __init led_platform_init(void)% ]/ c, k r9 G0 `
{
* L# G+ R% d# N9 L int ret;6 h1 u( n, @/ b4 r) _7 K- {
#if 0' {- ^/ W/ c4 b$ {0 d f! k5 A
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);7 ]+ _- Z/ Q* M$ [5 A
if (ret)1 X9 q* g2 h' ?) \0 S P$ c$ M
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
- U. E4 `: v0 i% G; ]: [8 Q "%d\n", ret);
6 @! H9 C" Z" [$ ], [#endif
4 M1 i1 x3 f7 k' W! x) p, Q1 @" e ret = platform_device_register(&da850_evm_tl_leds_device);5 d/ e# L% u# i5 {/ l9 K: s3 M
if (ret)9 H( ]2 e" q% ]! i% k# Q
pr_warning("Could not register som GPIO expander LEDS");& ` z5 T1 w# L; }
else
$ l8 ~! E1 J1 _3 R+ v) K printk(KERN_INFO "LED register sucessful!\n");& K6 { E n7 Y- Z; J& U7 Y
& M( M- G- b0 b O
return ret;% X6 a8 ~8 i2 l: k4 G. ? o" v
}
' ^5 L4 O4 W& x n4 ?! u$ `/ [/ I; E; [/ C$ f
static void __exit led_platform_exit(void)
2 P m9 `6 u' z{, V- U3 I5 w% ?# |9 \6 f2 z
platform_device_unregister(&da850_evm_tl_leds_device);
. x4 n3 s! ?" o# x6 o
% Q( I( r( r( B( F# T printk(KERN_INFO "LED unregister!\n");( A P) w: D7 _" y
}
3 f* }8 |- q. g$ o* d4 M i
9 H6 j5 R0 v) ]5 w9 `0 qmodule_init(led_platform_init);
5 Q# ]" r3 y& X6 [- @( Wmodule_exit(led_platform_exit);
1 _( P2 D1 G" o' A- j7 U+ x; e6 r2 n! E- C9 G, C$ y+ G8 S$ k
MODULE_DESCRIPTION("Led platform driver");
9 d9 S% I% F* p( I: F+ S \5 mMODULE_AUTHOR("Tronlong");/ ?6 w5 M5 H, O! U5 I1 e5 d: @+ [
MODULE_LICENSE("GPL");3 w% Y. C( f$ r: [
5 ^2 q% E% `' z; l
|
|