|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
R7 N/ R: ?6 P% x8 X0 k5 }9 z y#include <linux/init.h>5 f/ A6 ]6 B& _6 x8 p0 F: G6 V
#include <linux/module.h>
: v t- u: M! b' W' J#include <linux/kernel.h>' S5 U' o: n z1 o
#include <linux/types.h>% z. C% S7 b' d' v
#include <linux/gpio.h>. ~$ O/ ^5 j6 c! X) S; o
#include <linux/leds.h>$ C! }0 }; t1 V: w+ u) Z+ h8 Y
#include <linux/platform_device.h> o: H: z+ ^* N3 x) s
, k7 L- Y; T# L. A6 ]$ d#include <asm/mach-types.h>
8 Z# V" o. e9 ~. Y1 I; i#include <asm/mach/arch.h>$ q% [* Y( D! X# g* U0 l/ {) V
#include <mach/da8xx.h>
1 g1 ?6 v; H& i#include <mach/mux.h>8 z8 t0 ^' J0 Z C% i9 K
1 i1 i, U! q; j: f/ j#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)) r6 k3 ], r; b
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)! b: z" M' C3 c) g8 U6 p" A
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)& b6 _: l0 h4 y9 N2 C
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
: a% E8 A6 \9 r* ~" N* ?( s4 Q* h- w
e2 p0 h4 ~) z5 {/* assign the tl som board LED-GPIOs*/& Q3 w8 [. \% M( n$ p
static const short da850_evm_tl_user_led_pins[] = {/ D& \# }/ x2 U. _+ m" H
/* These pins are definition at <mach/mux.h> file */" L* L' F8 J7 L; H) R% c2 m1 q
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,0 z# E1 K" b0 Q0 I' m
-1
! |$ @+ e N7 s2 D};9 Y4 n4 p8 |, F9 c
- C5 t; N0 }; ~9 cstatic struct gpio_led da850_evm_tl_leds[] = {
t1 M ?5 w- O1 r! H {1 W2 e8 `6 D/ ]+ G
.active_low = 0,
) u- I1 z/ o9 v/ v" [4 {7 @ .gpio = DA850_USER_LED0,8 ]- n1 F$ W4 w% h0 j7 T4 |( F5 J
.name = "user_led0",9 W! C& \ ^ U; C
.default_trigger = "default-on",
. M! e+ h4 e' _5 I; e& Y },. g0 X, {- {; ?; n
{: R: I- m9 u5 t8 j1 y5 Y2 x
.active_low = 0,0 ]4 H. a1 {0 d$ j1 }
.gpio = DA850_USER_LED1,/ A# p4 P [. W% e8 I1 ]0 C' A1 P
.name = "user_led1",
0 U# e7 A2 o4 M2 j4 Z# I, f; F .default_trigger = "default-on",
* A5 z1 J( |9 H5 G S },, S( x' H9 b3 T, _
{
4 c+ U& c. I) O8 H `/ F .active_low = 0,) b3 {6 ?9 }2 O: G: H
.gpio = DA850_USER_LED2,* i! G# U. q7 U6 V
.name = "user_led2",
+ {4 k- n2 `& C! i% }, _, \' E& f .default_trigger = "default-on",
r2 b' q/ I: b" c0 J, z$ ?9 y },* z' k( h; r: z* N1 I" i9 ]! u, q
{
; i: J. ~$ l4 ~2 @ .active_low = 0,
: C- M: P% U# j. c, S .gpio = DA850_USER_LED3,
; E. e- V+ j9 w# c .name = "user_led3",1 c4 l: _1 R, W, D" H
.default_trigger = "default-on",
1 ^4 E- L- T+ u9 g. H },
' Y/ r( U0 N/ G. P6 o: `};2 Q5 v# `; {9 `, I" k! W
4 Q- n# p( B; Q( X6 j$ n$ ^static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {2 ^) G/ A8 n$ {" E1 K% P
.leds = da850_evm_tl_leds,
1 r5 F, w6 C/ e: {0 x .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
" `' c& B. o* I};" q+ t; C. I& L& h5 O5 {5 f
: D& O$ z4 c; f$ I W& I4 Lstatic void led_dev_release(struct device *dev)
* p8 A+ N( c6 i{
4 j# H6 P2 G( T( V; k1 O$ u};
6 r! L: g# }# l" @1 u' A0 {6 O) V+ X6 p0 u0 h
static struct platform_device da850_evm_tl_leds_device = {
* T& f1 Y E; S6 T4 }- r2 v .name = "leds-gpio",; q( }6 \# n' Z/ l. |+ V& {
.id = 1,' l& u* g7 C8 E C: J
.dev = {
& u _* Z4 x; E2 o X/ B .platform_data = &da850_evm_tl_leds_pdata,
' w) L; m& {% d \1 L4 Z1 Y .release = led_dev_release,
7 z% |! p8 g, T$ ?& I, ? }2 c, O, N9 d8 |; o Z0 e0 y* e5 o
};. A: l0 U( b; C: A7 h2 I( h f4 A4 Z0 ^
" u1 g. u6 A* ~static int __init led_platform_init(void)/ a# x* D' @/ \
{
, K( i$ C! D& w% q6 X int ret;
8 H6 n: ^& Y4 h6 |#if 0
/ J# I& P ^: i5 b) ] ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);, k: ^- y4 y2 M& f6 I
if (ret)
; b9 S$ z" N, g. H pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
) X; k" l- T: ]+ n. Z "%d\n", ret);
9 M; k g% `4 G' s#endif; J) g. W( H/ ^
ret = platform_device_register(&da850_evm_tl_leds_device);
4 h s4 t! F3 g if (ret)8 K W9 o2 u9 Q2 `0 t+ t
pr_warning("Could not register som GPIO expander LEDS");
( j1 {0 a, `/ W( G! a- H else
, p' y$ T: {9 ]1 t3 J0 z" p printk(KERN_INFO "LED register sucessful!\n"); d8 x/ a8 U/ f" w
6 A3 i7 v# D5 j( U. R
return ret;* u" M- }9 y2 G6 S- {, I8 Z
}
+ \" R5 c) s! e! D4 y) ~' `5 r0 z
static void __exit led_platform_exit(void)
- M9 x- }8 L0 ]7 E9 X{+ H$ E6 `5 w' L& R% s
platform_device_unregister(&da850_evm_tl_leds_device);
. U% U9 s b6 F1 q: u$ K( y8 r! a7 a3 v$ W
printk(KERN_INFO "LED unregister!\n");
8 l Y( y9 l: A2 f$ M+ H}
5 B. c9 J: S5 U! M
8 x5 [/ j6 h* m7 _module_init(led_platform_init);8 A) s/ i7 `3 t4 K; g' d' \ s9 x
module_exit(led_platform_exit);
* q& h! {2 ]8 A) S6 `7 k; X4 ^, G- n0 h. N$ q+ Z3 f
MODULE_DESCRIPTION("Led platform driver"); P6 N Z2 E9 T7 J, q
MODULE_AUTHOR("Tronlong");! K0 q v( V% M# D( C' x( L
MODULE_LICENSE("GPL");
" J$ a; n( q; u5 N5 q7 \" u4 v( X% |+ v$ U! j9 M- _
|
|