|
|
求大神给下面的程序做注解,请稍详细些,谢谢。2 ~! z9 _. O4 @: c
#include <linux/init.h>
7 ?+ Y0 |9 N l: ]; U8 G- ?! _#include <linux/module.h>3 _. E* x# t S6 B
#include <linux/kernel.h>4 s! ?! x- E" B
#include <linux/types.h>
( F9 Z# z1 E5 P9 J#include <linux/gpio.h>' A" L0 ~) ?6 R" k4 W+ H% n8 m
#include <linux/leds.h>/ t4 x7 Y4 A; K* m: N' S, U
#include <linux/platform_device.h> X) h! y6 Y4 _0 _+ E4 u
, v' Q# @4 M! K! W; o
#include <asm/mach-types.h>* c6 c: y* G) ?( ]$ S& ^. \
#include <asm/mach/arch.h>2 S+ I' i5 ?; E# D
#include <mach/da8xx.h>
7 v/ A; O" F8 _8 o: { l#include <mach/mux.h>
5 k8 ~- x3 k" k
q! E/ v7 _' U) G: ?3 l6 _#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)! c- A- @" y; J% W. n4 q: _8 ~
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)( Q9 D$ k8 w% W |) ?5 z/ {$ l( ~4 q6 z
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
% P8 J2 I) v- b+ y0 f, K& e#define DA850_USER_LED3 GPIO_TO_PIN(0, 2); ^$ O: u8 l( ?+ X( @
0 L- t7 K: j8 ?9 ~6 f0 J6 i) R2 P
/* assign the tl som board LED-GPIOs*/
- R+ X" x; k* n/ y! Gstatic const short da850_evm_tl_user_led_pins[] = {# S: e K5 ?, P
/* These pins are definition at <mach/mux.h> file */
3 S+ x, x$ \% j3 m) S# T8 t; r u DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,9 @4 w: }* R: d j" n+ N
-1
& w# r* S& i1 c: A+ s9 }};
- G8 W/ |" G, B* s- e2 _) f4 o4 y) Y2 L6 Y: S- L6 v" q% s
static struct gpio_led da850_evm_tl_leds[] = {
( l" a+ C9 ]) u3 F' \2 I {
9 x- F4 \. I4 Y! S4 Z .active_low = 0,2 [5 ]# ]& Q+ O4 p
.gpio = DA850_USER_LED0,
* y/ o% A/ D7 u .name = "user_led0",1 s9 c5 z7 Y8 _: I
.default_trigger = "default-on",! V/ P. N$ Y* ~$ n* k3 u
},
# o9 _+ h0 w7 M {' V% s5 u Q+ ~3 G' L
.active_low = 0,
' B! T( j0 ^' H3 d .gpio = DA850_USER_LED1,
! P1 P4 ^' @; Y5 f: ?& R& j2 H .name = "user_led1",$ `* f3 x2 y% y: g+ A; s
.default_trigger = "default-on",
/ a4 c9 h9 d4 h },3 L) N& s0 I$ i3 t
{3 w9 k, ?/ T2 P4 b& I" w
.active_low = 0,6 Q, e4 k; e* _* [
.gpio = DA850_USER_LED2,2 Q. m- F! ~1 `7 K" A: I0 R+ m$ O
.name = "user_led2",) ?$ l0 v$ a: a$ N8 d+ j
.default_trigger = "default-on",' D5 w+ C3 v, `7 P4 V, {
},
8 H H4 q3 v; v5 [. B4 G% S, `- _6 t {- X$ E; ]5 i4 {* g( _
.active_low = 0,5 P3 |( D; c) _
.gpio = DA850_USER_LED3,) U' H* X0 \9 x9 W
.name = "user_led3",
6 j3 {) K$ x$ {7 D .default_trigger = "default-on",
* y0 Z8 E& Y, E- q" {* O t },
. W* _9 ^5 e" {* }, Q};
, F6 Y5 P# j: p1 W" D+ q q
d: M2 g/ i6 r0 Q& @, mstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
8 C& X/ |2 q* Q$ D: C( D4 c# @ .leds = da850_evm_tl_leds,
/ H, z7 ?1 P$ h ~ .num_leds = ARRAY_SIZE(da850_evm_tl_leds),8 c# H# c# ^1 [1 _( R
};
% L% q3 f5 ?+ V' [( s3 `
2 j+ z# e: S# fstatic void led_dev_release(struct device *dev)
% Z v& `. a5 ]0 V{
9 `5 u, l& o- t4 u0 b- m& o};
, O! ]; n: x+ q1 E7 D% k: O$ V P
static struct platform_device da850_evm_tl_leds_device = {* j" M2 U+ \- A) R( _4 m
.name = "leds-gpio",$ v, p8 \$ C& t+ F" Y
.id = 1,
* z% X1 C$ R7 w) m# M `4 J .dev = {) b4 G) }9 n+ \$ X; I
.platform_data = &da850_evm_tl_leds_pdata,- G& w% N: a) S
.release = led_dev_release,7 Z0 a: r K* o8 c) P, A+ w6 t
}
- v. g4 @: T: n% c- ]1 E};
; f7 \ r2 X0 h% J$ o! o% X( f0 ~: d' F, h$ X- V7 c
static int __init led_platform_init(void)
. I% W; f2 a# a& y/ f1 S{
! F) \7 `+ z: ?2 K$ q7 g. M: S int ret;
" B, [' P6 a8 y# _; @' T0 Z#if 0
& Z3 ~6 K! z0 f8 E4 o ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);% W8 S0 J. J" b0 ?* _
if (ret)
; ]" W3 G6 Z# d7 O2 B pr_warning("da850_evm_tl_leds_init : User LED mux failed :" i9 e0 C) o8 V) R$ R/ m
"%d\n", ret);/ }7 U% `; l1 Y# y# ?
#endif
% j/ S# z# M- M$ R ret = platform_device_register(&da850_evm_tl_leds_device);
+ L; R _. e1 a n/ Q$ ], J) l: }* I if (ret)2 n& l! r; Y2 u/ @# t/ W4 m
pr_warning("Could not register som GPIO expander LEDS");
( J: L, w/ X2 B- C else! O$ J T* Z& h! s8 v m- Y
printk(KERN_INFO "LED register sucessful!\n");( H4 w0 _5 J) \. v9 S
! ]8 d5 k" A7 p+ k% W' m- n* u* x return ret;
2 }/ `. D8 x2 X8 K}. w4 {( I. q2 y5 V. }/ Q4 X, W
; M. Q q+ e5 ?1 p
static void __exit led_platform_exit(void)5 p+ b/ n& U- i' l4 S/ L h
{
- |8 X/ T7 J: O- l5 `+ { platform_device_unregister(&da850_evm_tl_leds_device);$ u$ U* m) v) n
! k$ z7 o w: t: U3 m
printk(KERN_INFO "LED unregister!\n");
$ b4 e$ u- h6 c3 T} p4 l" q5 k$ S* E
% ~ ~' a2 F( z$ ^
module_init(led_platform_init);6 [! k5 ]8 \3 w0 m( u5 V O4 L
module_exit(led_platform_exit);
( h, {* K9 i5 `- `/ b- \& _3 c
3 `& w) p$ G8 h. B5 OMODULE_DESCRIPTION("Led platform driver");
/ k* D8 `7 k$ ` v1 S% |- p, d/ s6 XMODULE_AUTHOR("Tronlong");2 B. g. ~# i( c- I2 h3 M
MODULE_LICENSE("GPL");# f! S0 P0 g3 G6 h5 h0 ~* F
7 k( x( T( S) Z. O: C4 N
|
|