|
求大神给下面的程序做注解,请稍详细些,谢谢。
+ l- h: z, w: f2 h" A#include <linux/init.h>
/ l, @ b. \5 |( O3 }" m# v3 s#include <linux/module.h>
) R: ^& {. O/ K4 {#include <linux/kernel.h>) ?8 P8 b$ d3 t. {7 J; Q
#include <linux/types.h>
% ~9 `0 E% M5 ^3 s+ q v#include <linux/gpio.h>7 X s! @% T! U/ J
#include <linux/leds.h>% [6 W% m5 v; W& O; ~- \2 I0 X
#include <linux/platform_device.h>
/ r( l9 F8 L; b. ^" ]& Q0 I' v4 ^2 G9 V2 C# x9 ^! N/ F
#include <asm/mach-types.h>: A( t- D% X7 V! J7 }
#include <asm/mach/arch.h> Z4 Y ?) v) a) A) l1 {
#include <mach/da8xx.h>. c' j M/ S4 {2 Y9 A
#include <mach/mux.h>
2 ?# A5 w! v$ }5 T
- a% J; Q% M' n3 B/ b& K#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)' v) F P2 l' L% G, o" w9 V
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)& z6 u$ b2 c) C; Z+ v
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)4 ^' y# S1 J, A, l. l$ U
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
7 z9 `+ T* `- M* V
4 H4 i/ S& q1 y7 g0 g/ [( {/* assign the tl som board LED-GPIOs*/
# E0 b* y$ k( S; C1 `! ]static const short da850_evm_tl_user_led_pins[] = {8 a% V9 _( {0 P2 y& S* p
/* These pins are definition at <mach/mux.h> file */
9 h4 V) v& u) T7 d5 a DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,( X& ?0 g! X- v# Y+ m6 T7 ~5 K
-1
6 o! `$ x% L& b% x) R3 f) W; `; _};% P4 n$ E! ?& [: p& Q% D
/ W7 ?0 R& i+ z2 Jstatic struct gpio_led da850_evm_tl_leds[] = {* S# w' l; s7 U- |9 {9 u
{: L6 X$ W6 U0 C3 _
.active_low = 0,
9 ?) ?- u% X$ w3 N/ `$ G; d8 n, T, K .gpio = DA850_USER_LED0,( x- r$ [$ E8 w4 p5 i0 b. i Z
.name = "user_led0",9 A% _7 h; I. u9 x1 M
.default_trigger = "default-on", Q5 ], T, u* ?- u0 @1 [
},* c' E4 ?" N& G9 z4 F
{
" ]& H- j6 _. U( d .active_low = 0,. K7 p* v/ p! ^% X @, a. f8 }4 }
.gpio = DA850_USER_LED1,
+ f3 [: b5 P. b .name = "user_led1",
, e) c0 `9 U: C9 P7 o .default_trigger = "default-on",
4 X- [. Z( b/ l, [) I& g },4 ~5 V' E' \# t* x
{
- z& V" {; i) r" y .active_low = 0,
1 ~$ B) Q" k9 M# G. l1 a6 D$ ~* A; O* R .gpio = DA850_USER_LED2,/ g1 U4 ~- l+ ?3 U2 j. S) _
.name = "user_led2",
( {% I( j7 e8 h .default_trigger = "default-on",
/ b1 ~! W' B' O7 k+ n },+ n6 m0 `8 q3 n9 z
{
: l5 }- k3 |; d .active_low = 0,! n( |4 C- A2 C3 ~& D
.gpio = DA850_USER_LED3,& i4 T. }* J; c# P* S0 n
.name = "user_led3",
- A5 u* N3 F1 v9 _! R5 w .default_trigger = "default-on",
, ?7 v. h9 y8 G6 ^* S },
+ P1 d3 |" v. `7 N4 y0 R};. r6 y: J# q5 K3 v4 X! I
* ?$ F' ~5 s0 r# K1 r! Ustatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
3 w7 H" I1 c! x) L- ~' b) g .leds = da850_evm_tl_leds,: \+ m% v& b/ y5 N
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),. v- H2 _2 [% c( P6 L7 I5 [' `
};6 a# c0 A/ g9 P% Z" m4 s# S
3 d& N! ?9 ~. s' X5 Hstatic void led_dev_release(struct device *dev)8 v% P2 r" Q: _- k8 k$ e- n
{
0 Q5 Q u$ I: Q};
, k4 d9 F- y& x0 G: \: V3 E" b9 j; |4 a5 ]5 l
static struct platform_device da850_evm_tl_leds_device = {
$ W1 X6 @' [* @ .name = "leds-gpio",
9 l" f! j- R; T) y" x .id = 1,
9 Q" ^$ S4 @3 Z8 u/ k1 ] .dev = {
! J& z) |7 s4 Y .platform_data = &da850_evm_tl_leds_pdata,
7 L0 B% n: r/ l* R$ ] .release = led_dev_release,
& g# d* ^9 {6 @. }* Q/ m }
. Q8 @; l' @4 z" q: |};
, P% o8 R' y, _9 k0 J8 Z0 q( O8 J7 v9 |0 B) u0 n. E, ^
static int __init led_platform_init(void)
% i: m( f% o! t3 E W{) X# `4 F! B! F% w! K; k
int ret;+ f: u L( M6 e8 {, Z2 q; @! g
#if 0
; J" {6 N( z- D! U: u ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);' L# k& Y6 e- v& O2 A
if (ret)3 c. V5 J% C+ F4 r1 k& l
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
; F/ h+ }; D0 K& E% R0 i "%d\n", ret);2 Z! [/ g C; C$ C$ V
#endif4 }( [/ l/ V# o: Q! r8 D* V! P9 x
ret = platform_device_register(&da850_evm_tl_leds_device);
# ^5 @( p9 j1 X# e1 X m, _/ l if (ret)1 u( j& i) P3 |
pr_warning("Could not register som GPIO expander LEDS");/ V5 d# h. a) {1 |3 ~$ i8 L- I
else
0 h' i! y& y9 p2 M' t& p printk(KERN_INFO "LED register sucessful!\n");
6 l t6 @. Y. |- h' ^- U& f3 g/ e0 k! z4 e* v& N' _' {
return ret;
& r6 B ]1 D' u$ i2 r |}
; m+ E2 a/ ^8 m/ b) q f2 a! Y4 f! D, f/ v3 o
static void __exit led_platform_exit(void)
; T7 {) p2 P3 b9 {! M$ ^" C- D& |{
7 D7 Q4 m& ?/ F5 h$ Q& o4 F platform_device_unregister(&da850_evm_tl_leds_device);4 D$ T6 G# T: ^1 f
# G$ `4 o. q& A4 d8 k- i
printk(KERN_INFO "LED unregister!\n");
0 c8 }" L0 B+ X$ w}/ V' b# [7 N3 s# S
1 K* e; v6 _5 G7 d4 v% }. jmodule_init(led_platform_init);! L5 {5 L% W9 ^7 ]
module_exit(led_platform_exit);
) `) M0 s% f9 f, q5 \ n/ J3 V' v+ ~$ p4 }" O4 w* P! M
MODULE_DESCRIPTION("Led platform driver");* N$ f4 V) j- S) d& [$ o
MODULE_AUTHOR("Tronlong");# _4 c" S0 n3 ^
MODULE_LICENSE("GPL");
- E" `- |, y {. J. @: N( x
6 k T) B8 u& Y) _ |
|