|
|
求大神给下面的程序做注解,请稍详细些,谢谢。8 j, |7 G% X4 X! G; y
#include <linux/init.h>9 s2 M0 B: b8 T! z0 @$ C. E
#include <linux/module.h>/ n/ X! w0 G. n# B, Z
#include <linux/kernel.h>1 z4 S8 |; X: R \7 F
#include <linux/types.h>
& v$ q: B9 J5 B* G) f! G' b#include <linux/gpio.h>
5 g# s- `5 x# n3 k#include <linux/leds.h>5 Z% f& [& n, `, i
#include <linux/platform_device.h>
3 U( L+ L m# U) G9 u8 Y! u5 ^4 F0 a5 w7 ~! F) |
#include <asm/mach-types.h>" w+ R; Z: T0 @& w; o" M' U
#include <asm/mach/arch.h>) n' y% j1 J4 M; e
#include <mach/da8xx.h>0 f+ ^1 g( X) a# O! h
#include <mach/mux.h>
* q: F( B3 `+ Z: l0 x# ]2 k3 b& D# b, G
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
, t5 l1 c/ y+ [1 o4 [/ Q' {5 l#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)" I. m F t4 ?" M0 o2 z
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1) d* n% p$ i) C- b; }( j
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
6 p& S& B' `9 A& O1 ~. N( @; V% |! ~& n* x- e* `
/* assign the tl som board LED-GPIOs*/
: Z# r# j: b' Qstatic const short da850_evm_tl_user_led_pins[] = {6 o" R5 _' Q4 u! Y9 N) s
/* These pins are definition at <mach/mux.h> file */! n; ^1 o* E7 j9 J5 c
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
; A! w% D6 s" D" f' t; K5 Y7 O* X -1
6 L, M* D! B- W};$ O$ g5 {, F0 Q0 e( G" ?' Y5 N
: ?/ A1 D! i& w/ d
static struct gpio_led da850_evm_tl_leds[] = {$ y$ T; y- c9 @% q- O- ^# H+ A0 w
{# B- C0 _, y% T2 ]9 S
.active_low = 0,
2 j1 F- y8 q, y; A .gpio = DA850_USER_LED0,
, e; K. T2 H8 S6 p7 _7 H# r8 C# G( Y .name = "user_led0",- O; Y- ^! |4 g
.default_trigger = "default-on",2 E" n O! K! F
},0 l* o0 S, m9 _7 m
{
5 f3 Y" d) S% @. A7 U .active_low = 0,
; O" `" l7 W. @) B .gpio = DA850_USER_LED1,
& P. c! b# S7 a3 X4 D .name = "user_led1",
' O5 X5 O7 w3 m; H8 J) z! ?" ] .default_trigger = "default-on",& \) L# P8 u: c) j6 ^- Z4 I& M! F5 M- Y
},6 Q1 n5 B8 ]2 F* y! {4 R
{) z( x+ G4 t; @' t
.active_low = 0,
: o$ K( ]7 o& J& J8 I( J/ h .gpio = DA850_USER_LED2,
- {2 ]% q4 i' r' [% d .name = "user_led2",
4 a7 ?1 Q6 ]8 K( ~ .default_trigger = "default-on",- M; V2 r' G6 N6 e" H1 D L8 s
},' g1 f0 y1 H1 m% T7 V4 h8 Y
{
+ d/ U: L9 m. s' j) G .active_low = 0,- x" K) F u" g8 G
.gpio = DA850_USER_LED3,
^6 d/ M# c/ {6 y .name = "user_led3",
! _3 ^ F* s0 P! `7 u .default_trigger = "default-on",/ Z" o: q! T- o. z# s
},
6 F2 O8 e# x/ O6 I2 t! u8 e( b6 |1 b};! l' l1 U8 X1 Z; }! [' C! z. w
) K V# O- ~4 o6 M$ ?$ e
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {, F# y# [ P. J
.leds = da850_evm_tl_leds,1 p/ L+ V3 g# }/ d2 Q0 v
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),+ u$ }7 q+ ]; B5 I' e0 t
};
6 F9 b7 s" c8 ~ V2 @' O% m% }0 F- R: g& b9 h9 |' |
static void led_dev_release(struct device *dev)" Q+ b C1 Q6 w8 T8 X( }' K
{
+ a6 E; W6 A: z, Q* M& u};3 }* A5 ~' {6 W- y& D! T- B3 F5 T
3 V% U* y! k5 g- Z
static struct platform_device da850_evm_tl_leds_device = {# R( O9 F) D% O: n) _
.name = "leds-gpio",! x/ G+ [, z& D4 ^; [
.id = 1,
6 w0 W7 G0 W. W3 U5 F .dev = {+ C" z; I, R& V" i& ~* M/ K: K
.platform_data = &da850_evm_tl_leds_pdata,9 R2 Y( e# g+ _* Q& h, F, i
.release = led_dev_release, ^ b9 K( |2 \+ e
}
, F4 \- ~6 J& q6 V9 o% r6 u};6 _0 B3 X% q2 K" U$ A3 {
% x3 T7 G; W% s4 N+ R% Y
static int __init led_platform_init(void)
, G2 a6 B3 o) F7 C' S0 }2 i{
; `' L0 x' i* B! ~$ b int ret;
# M) Z+ x6 R N: K: \#if 01 M5 f, i$ y) Q- G2 S: U
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);0 z e$ {* ?' u+ y1 Y% g l
if (ret)
, P$ |& P& ^# T8 i4 B7 F pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
- `2 t) E1 }* ~3 H, a+ x "%d\n", ret);
' p/ d% r- X: g#endif% f' T, N9 S" p3 R' R ]3 |
ret = platform_device_register(&da850_evm_tl_leds_device);( o+ d% O( y* R
if (ret)
: {1 R. }% O/ a- [9 A8 ]5 G pr_warning("Could not register som GPIO expander LEDS"); Y0 v9 y- c p1 X, \
else/ w6 m+ Y W% d- N k
printk(KERN_INFO "LED register sucessful!\n");0 p% O! R- \# Q5 D
! ^' G" K& |/ i' n return ret;, I/ \, I, D' w
}& R {- N7 K5 A) T& y+ o
1 S+ R0 _3 N- z3 H
static void __exit led_platform_exit(void)
1 ]8 h, w) ^. R0 Z6 \. q* P{
6 @# w( h) Q$ o5 m+ s6 @ platform_device_unregister(&da850_evm_tl_leds_device);1 m* I" i" m: F3 p
( J1 l1 ~8 j L printk(KERN_INFO "LED unregister!\n");
8 [4 c7 b/ }3 `6 Q+ N/ m- }}) p8 ^1 e9 i- n; t9 `; N7 i
* i% g& ~# O9 W" {
module_init(led_platform_init);
, C2 T$ `3 \8 Y9 {# J+ H$ d8 Xmodule_exit(led_platform_exit);* L c& c+ N: I( q# y* Q0 ~0 c- N
" \9 z$ _ ?, ]5 i: I
MODULE_DESCRIPTION("Led platform driver");
3 c2 f3 Z: E, C( b' R% v3 a$ ZMODULE_AUTHOR("Tronlong");
( V- T1 ^- k9 n4 a4 CMODULE_LICENSE("GPL");+ u" O( z& Y0 u1 r9 u
* a- d, C* [" w; R |
|