|
|
求大神给下面的程序做注解,请稍详细些,谢谢。- D8 v+ w/ n% v
#include <linux/init.h>1 {7 F- e" T1 t8 O8 @ F
#include <linux/module.h>
0 D" B: }4 A+ K2 W; G4 X#include <linux/kernel.h>
+ u& }9 e* e/ F#include <linux/types.h>
/ R, u8 [. L: q" Y- u* [5 U2 f& c E o#include <linux/gpio.h>1 }2 q& w% N! R! C( j( k
#include <linux/leds.h>) F! x% u" p5 R. D$ y) G
#include <linux/platform_device.h>
8 {& u# c# `- b9 D' L. f
- N1 J9 f8 b/ Z, i% p' f. ?#include <asm/mach-types.h>
' F9 H! ]- V: c8 m1 Q6 Z% v#include <asm/mach/arch.h>
9 G/ }# t6 ?$ l7 d0 d6 {4 ~: A1 C) ]% ^#include <mach/da8xx.h>
1 ?* ]6 F/ X0 B9 u#include <mach/mux.h># ^! F k( E3 X/ n; @% d1 j- h/ p
% w; M, d2 _, w( [. @ {
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
+ y0 s( R* F5 o" _4 @1 ?4 Q$ l#define DA850_USER_LED1 GPIO_TO_PIN(0, 5), a( j# s d: s9 x1 [2 m
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)0 `- ^6 D- o! E' U* o7 s2 y
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
+ n3 b7 ?% p3 L$ `2 e
$ O; S3 t4 t j8 G+ r/* assign the tl som board LED-GPIOs*/
/ _ v& H# G H. l8 F" xstatic const short da850_evm_tl_user_led_pins[] = {3 o- G" k" V6 \6 O. l9 Z) z( y
/* These pins are definition at <mach/mux.h> file */' Y4 T2 }9 P0 q/ D+ o
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
9 o( [. l0 `+ w f! r# b4 D -1# w! |; F; p z/ v" J
};
' {/ q: l5 D& i
8 [) p9 L5 h- E7 r+ a- \0 p3 q' @static struct gpio_led da850_evm_tl_leds[] = {
* t* F. A6 e; X4 V3 J- C {
2 ^" g. Z# v* z) w: I u* v# f .active_low = 0,
+ u& ~8 H: Y. O T- S6 ? .gpio = DA850_USER_LED0,
7 l4 ?; y/ t( P; T, k E _; B .name = "user_led0",
1 A) r* V, I$ d; T y" B .default_trigger = "default-on",
: D) R# `4 }, }5 D, r. Z, ` },- g7 X9 @1 a# A. s) J' x
{/ I7 A6 L$ |3 m
.active_low = 0,7 @/ X1 A9 ]- O) P( P6 H
.gpio = DA850_USER_LED1,# M9 R! O# f/ G1 g% ?, r0 D) G0 b
.name = "user_led1",! N$ A; ], P+ G J$ C' D
.default_trigger = "default-on",
% l2 P; J) {) X# M. ^0 [ },
5 m ~2 }" W( I/ \6 k' [9 j- F U3 g8 q {( }# T8 t9 b8 j* }
.active_low = 0,- e/ c* {7 _0 ]3 ]
.gpio = DA850_USER_LED2,5 _9 z# X6 _6 e7 V' O8 Z* I
.name = "user_led2",& I7 K) ]8 I/ K8 l
.default_trigger = "default-on",
) A) E! r3 H( C5 W },
D- |7 [8 x( r, f+ b {
% B1 E$ q! w% o$ u$ _ .active_low = 0,, |; D; \7 D8 Q/ H: n
.gpio = DA850_USER_LED3,# |& n8 v& w) Y7 x
.name = "user_led3",
$ |3 y6 c/ i. w& s .default_trigger = "default-on", |3 {5 s7 z" `% P2 o8 `8 S
},
v+ c6 m4 P- V7 F" z};
R0 `) C6 H; l6 W+ H( v, i5 W& @( Y' Q1 J
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {5 n) J1 w) I' ~6 z! f& k- @: Q8 y- ~
.leds = da850_evm_tl_leds,
* s8 W2 {# _7 P' k. D .num_leds = ARRAY_SIZE(da850_evm_tl_leds),. x' o$ }4 d+ {( A8 C6 ?
};
7 N% [/ r: X$ `4 |5 D, F6 v, x: ? z4 I, _2 R2 h. A3 I% b
static void led_dev_release(struct device *dev)/ v3 R7 E* U, v/ |: r1 a0 k
{2 `7 W1 h7 R6 ?' f* s
};
4 Y) }* a# s& s: }' _: y8 U( j0 R9 z$ y- ]5 r3 I
static struct platform_device da850_evm_tl_leds_device = {6 i( y4 k) H H" e' o1 U/ Q( | x6 _
.name = "leds-gpio",; R. J5 h# A- B D3 z
.id = 1,. Y' N9 g9 O6 J' n8 K+ i- ]
.dev = {: j; Z6 P* ^ s
.platform_data = &da850_evm_tl_leds_pdata,1 C0 O% S/ g4 ~! t y3 p+ [0 v
.release = led_dev_release,; e4 c8 q* v1 M# ~
}
1 R# r6 X! S. |; w# a% j};
. z: U$ r. q$ _3 G9 i% |
% G; H) l& w1 p- [static int __init led_platform_init(void)( D) L g: R! S t. b6 D
{
' w" Q0 P: @" G; R1 \# F int ret;7 Y! p A6 X! M7 {
#if 0
) S" W; s- g# e+ e3 y ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
# k6 z0 u; f* A9 H$ z if (ret)
9 ~# Q6 m* B4 v( c pr_warning("da850_evm_tl_leds_init : User LED mux failed :") J4 r# D, P3 `) o6 @. T
"%d\n", ret);' ~0 ? A8 o# a
#endif
& f, j2 e. h6 H2 a1 O3 |/ x' J ret = platform_device_register(&da850_evm_tl_leds_device);* o* h5 v }, I$ v# a* |9 |/ V
if (ret)
2 f/ a; m: B" T- d. ^4 X pr_warning("Could not register som GPIO expander LEDS");
. p. ^; m3 N: h7 i, T6 Q! _/ N. Z" q else9 K2 K% X* z2 f9 M8 \8 u- l
printk(KERN_INFO "LED register sucessful!\n");% |4 v% r5 L# U0 F* Z
R8 w1 D0 F. Q1 @! ?# P return ret;
/ }1 R% o9 {- L9 _; W$ a}
! K$ {8 }2 C" I0 R. E! V6 L9 j( @0 k8 Z( M
static void __exit led_platform_exit(void)
9 W% a: j' {! D# x6 V9 ?$ O- j{+ v, Z% F, c }: L! s3 t2 t
platform_device_unregister(&da850_evm_tl_leds_device);
2 G* f7 e# ?) E% u7 K. K( r. J: p) K$ o6 Q% Y
printk(KERN_INFO "LED unregister!\n");- r5 w% A \# L. s: ?, K
}& e( ^ ~9 f6 A; j% i; j
2 x% Q1 a+ X' e
module_init(led_platform_init);
* ?3 e2 Z9 q% ^# I6 k4 v& kmodule_exit(led_platform_exit);1 O$ O1 I/ ^+ B- m; d
& ?6 ^1 ~7 F! Q5 w, n4 S
MODULE_DESCRIPTION("Led platform driver");4 M ~6 o! u% k
MODULE_AUTHOR("Tronlong");
% H2 O1 F8 u! h, _& \MODULE_LICENSE("GPL");
# z. ]' V3 H# W0 ?! P0 k& V5 `0 S1 n8 ] G: c$ `
|
|