|
|
求大神给下面的程序做注解,请稍详细些,谢谢。( t- ^5 G" g0 ^9 u
#include <linux/init.h>( z/ A0 T9 S3 H6 V4 S0 }3 C
#include <linux/module.h>
/ @: W. |$ ^! N- ^# q4 q#include <linux/kernel.h>+ u# m2 j" K) N% B+ |
#include <linux/types.h>
2 F9 ?4 [( g" F) x, O- R& A#include <linux/gpio.h>
$ a9 M- T/ q- t#include <linux/leds.h>
6 U, v% B7 L2 [3 ~#include <linux/platform_device.h>
" r u5 M X, n9 W; t/ ?$ d" B$ B' y5 {" t6 D- E! x: ]
#include <asm/mach-types.h>7 N( [- ^( ?9 k- e0 `
#include <asm/mach/arch.h>% c# M4 y/ ?/ U- v
#include <mach/da8xx.h>
: J& W; k4 k9 Q* W3 c#include <mach/mux.h>
4 p2 q! M6 ?% r2 D1 K) n
# V0 R$ S3 E* D3 p( Y#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)& Z |, e: e! d. s! X. \8 d
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)7 f9 R* R5 r& z' ]+ y4 G" o
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)5 t# E4 c5 g9 V5 F
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
; o# }3 E& e/ F( W0 r0 g% M" H) x* \% ?2 q* z) O
/* assign the tl som board LED-GPIOs*/
2 r, ]2 @. N; C$ ~ O w8 Gstatic const short da850_evm_tl_user_led_pins[] = {
7 B6 ]% H; X9 [/ r /* These pins are definition at <mach/mux.h> file */
2 A; M) u2 C' s' C7 [8 Z+ k DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
9 n8 `) S! o5 B" V6 ` -19 C1 e. f& Y8 m2 `4 R4 h
};6 V1 l% j, ?4 ?$ j$ s
: P$ n$ L+ A1 V8 ~static struct gpio_led da850_evm_tl_leds[] = {1 c& n5 N1 J( \- G; P+ W. u
{5 ]0 ]& N) R. n- ~
.active_low = 0,) o& E: H, Z3 d1 P* \$ b4 I
.gpio = DA850_USER_LED0,2 Q: j5 D6 q/ ^1 @, G0 ?
.name = "user_led0",' W$ y( e+ u* t" I f I' r. a. W
.default_trigger = "default-on",1 z9 o+ Z; w" f" k
},; D0 {0 a2 J) W, R5 I
{* H, G: e; f$ A7 ]* n" L0 e
.active_low = 0,# q' M# {9 }5 P) X2 A. V
.gpio = DA850_USER_LED1,
' d' C# o4 h# c .name = "user_led1",
& [3 D0 e& s/ r: q: A' |; o .default_trigger = "default-on",
, V" k J' }, h; l: J; } },
& Y% P2 e7 f2 f+ @ {
5 b; A/ X. D" [; |; s .active_low = 0,
, Z$ q# U& ^3 X& H" W- t* }8 V .gpio = DA850_USER_LED2,& x7 V1 i3 M, [& Q, G1 u
.name = "user_led2",7 V b9 i/ B+ ?0 Z: x
.default_trigger = "default-on",% D2 v" c( i( A7 x0 } K
},
& @. L# T8 [% f! `, t {
+ V0 I/ K3 i( P+ I5 r! f6 o3 i .active_low = 0,) P- V# ^0 |. d9 z
.gpio = DA850_USER_LED3,6 X0 g* e6 X6 A1 [
.name = "user_led3",: d$ z0 C4 X( Q8 L2 y9 [: {
.default_trigger = "default-on",
) q0 v& q; q k& w9 _ },5 L+ ?7 \! C6 l2 ?: R# x
};
: a( J/ w+ p' Q A/ h/ ~. M) K1 P- F' q; v5 W
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {7 g% l. s0 A8 {, s% }# c4 k
.leds = da850_evm_tl_leds,
" z# @1 U5 M( Z- A# n .num_leds = ARRAY_SIZE(da850_evm_tl_leds),% L$ D9 N9 W$ |
};+ x: U% m5 `" [% K& y
+ N6 D$ ?; t1 v/ Q2 t* w& c; @
static void led_dev_release(struct device *dev)
3 T* h; u% D# G) t& e& B% Y7 m{/ j3 D" G8 _" o
};: y( M' h* z& L5 g
5 w( L8 A& X( Y% G; f$ ~0 ostatic struct platform_device da850_evm_tl_leds_device = {
1 E% t% R* ~: u" u3 q .name = "leds-gpio",
2 Y ^2 ?, z; C" O5 o' P .id = 1,; j# w$ }* C9 I1 p2 W% F1 x
.dev = {
! t: O c' z/ g1 {$ K, B .platform_data = &da850_evm_tl_leds_pdata,
! J5 X* p: v n8 @! n .release = led_dev_release,2 I) J& x s8 b2 ~
}+ k8 C) z! O& L+ c5 b
};& a5 S: C! K) D) [: t: R
0 v5 { v1 g& R/ r8 J8 Nstatic int __init led_platform_init(void)
4 \5 x) f6 t8 ]5 b$ d8 P3 P6 H{1 t6 V7 M- H3 w+ F1 b7 S) l$ t8 U. Z
int ret;4 V: p1 u: J A0 Y' m' t
#if 0
! {- H( H2 Q( X+ s& K9 S ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);. S. x M8 a9 a% I
if (ret)
* Y5 T0 ?2 m& l+ C* X; c pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
, x% h9 D* |+ g, e. L "%d\n", ret);; {2 \8 e% j0 p% o
#endif
# b3 t) s; E" e# s, M& [ ret = platform_device_register(&da850_evm_tl_leds_device);) I3 N# k: g, i1 P7 @& s. r
if (ret)
0 j1 p4 ?) w5 ~7 H pr_warning("Could not register som GPIO expander LEDS");
+ A- ~' i6 w% `- A$ e else
5 m: s6 A! l/ R! B0 S# D printk(KERN_INFO "LED register sucessful!\n");
: g; R6 Q; K' s0 B! d. g: M0 p
9 n& @( g$ D+ O" C3 B" i' b return ret;8 |. q) t1 `4 G: T$ C5 Q
}, L$ u8 Z) |$ V, [
( \' I& }. n1 \8 N/ K" P
static void __exit led_platform_exit(void)
* L' W' Z+ y$ u" N' ?{
. U0 x/ C9 h; c platform_device_unregister(&da850_evm_tl_leds_device);6 ^! F, t- g0 W2 j
* Z+ d' O) K! _% G printk(KERN_INFO "LED unregister!\n");
* {$ A8 k5 J* ]- _3 V}: I5 J3 C+ z% o( f& N6 C
j# S: w1 o" V+ W4 c% E& vmodule_init(led_platform_init); E9 \/ L9 V; K2 X6 e! `
module_exit(led_platform_exit);
3 a# D+ l) I; m1 n M
! t! Q- H" j' F) l9 WMODULE_DESCRIPTION("Led platform driver");
5 D6 }5 a. U2 TMODULE_AUTHOR("Tronlong");
% v/ W- R' X. ~/ `7 ?MODULE_LICENSE("GPL");
/ P& j; C: n* T U8 d3 |
, c! Z& B: L+ \, H$ Q9 t& { |
|