|
|
求大神给下面的程序做注解,请稍详细些,谢谢。+ N) ~8 i& }) [5 P* h/ h; P1 z, e
#include <linux/init.h>+ I( ^7 I9 S6 M T0 v& S
#include <linux/module.h>
' v$ N" P3 B+ r# v1 {- f0 i/ K1 L4 G#include <linux/kernel.h> Z/ J" n, U1 r# S" Q
#include <linux/types.h>
1 P, l2 E5 Y* i. l h#include <linux/gpio.h>- }( G4 k' u& m5 z5 u4 c# p( N
#include <linux/leds.h>* Z' h0 u: V. N, T0 o0 z4 @" G
#include <linux/platform_device.h>/ v5 N# V0 L5 m+ T, ^
6 L) L2 V" Z8 A! ^3 u#include <asm/mach-types.h>
3 w: m, k* G/ U1 _5 o; q- ~6 n& x#include <asm/mach/arch.h>$ [% a$ m- ^/ E9 q. K: G
#include <mach/da8xx.h>
5 d/ v5 h0 h' e; K8 B6 Q3 e#include <mach/mux.h>3 @" c2 Y: N! w: o/ g
$ q: a. H. z1 d) v: b
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)4 M4 U6 f; y" ]# W
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)" V& m' Q5 m: U7 g s- _7 ]/ ?
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1). t k# @- m7 u1 F, H
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)4 ?: c# ?; b0 w& e. B0 G) l
3 O b/ F5 u3 ]: R7 a' Q
/* assign the tl som board LED-GPIOs*/% @4 Q- N. z, F% k0 \; z1 S
static const short da850_evm_tl_user_led_pins[] = {( C5 g: \; M" E) Q7 T
/* These pins are definition at <mach/mux.h> file */
+ W3 _; v; Y8 d$ C DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
3 b, q2 s) O/ G% @- r6 ]$ x -16 n0 s i. |$ s+ s5 b
};
3 l6 k) H# n% u# v, t& S1 d$ H* G+ T, r8 J, B/ z4 J: P& p
static struct gpio_led da850_evm_tl_leds[] = {
9 ]) A3 m8 e m& \ {
8 [9 |9 R4 {. e0 U6 n+ I& \ .active_low = 0,
" ~) b' {) A* A/ u/ v0 V: I .gpio = DA850_USER_LED0,
$ _ R; g, c3 N; J' W .name = "user_led0",: w( w" D/ }4 ~5 q5 L- v
.default_trigger = "default-on",' r: ?! c$ X! ^
},% q' w5 e; j' D! u, p1 \. t2 L
{
4 I0 N) R' p( P3 A3 h! u .active_low = 0,8 Y9 k1 q6 | M3 b/ S/ V1 ?
.gpio = DA850_USER_LED1,
e% X; J* E+ }* M4 @ .name = "user_led1",, @& z/ ?. f4 e4 c2 F
.default_trigger = "default-on",
2 J& Q0 l' f3 O! ?3 O5 X# s },4 a; z6 P6 R7 H7 J: ?8 a
{5 L/ F% g2 y5 ?$ F
.active_low = 0,
# ~ ]2 E l8 |. M* A0 T .gpio = DA850_USER_LED2,
0 J* |* r0 L9 K! A+ j5 o/ @ S .name = "user_led2",$ \! A4 N- _2 o- F
.default_trigger = "default-on",
3 d0 N+ c) f f7 r' e5 [6 j },% G/ Z( ?) m9 \ ~
{; y" {" c; S5 o4 W; j- K5 O
.active_low = 0,
0 @ E, b: P6 t) j3 I1 k .gpio = DA850_USER_LED3,
5 h i. v t5 I, C .name = "user_led3",
2 ?" h) D" R5 x/ N% C- _ .default_trigger = "default-on",
" Y8 A4 ^8 c! M0 l* ? },
Z, w: K4 K, O* S" b$ C) C};
h+ X* `/ [* l5 T1 b
3 R2 t& x! C" n O* q8 s: Estatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
# R2 T* D7 X5 s" t2 v0 ^8 m .leds = da850_evm_tl_leds,
9 T4 p- i' h: J& U! ^0 |* n .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
8 M9 Q6 X. l3 y: i8 _, H1 D/ R) T};
8 ]- V. B, `- k! d; V2 `' ?& U
a; [; d0 ]% p+ x5 Hstatic void led_dev_release(struct device *dev)1 e( m8 i. Y: {# t$ W. V
{+ B& R9 L6 G; c8 `
};
: L9 O$ e1 a K. M( ~/ ?
* s; Y7 T% X7 q2 W& Q0 U& G ostatic struct platform_device da850_evm_tl_leds_device = {
6 A- L# a: E' q) @% Y .name = "leds-gpio",
" D8 j& H& \# q0 Y d0 M% D' @ .id = 1,
$ f6 n0 ?1 H% {; k: f- G .dev = {7 _% \ j. [+ [, w: C4 q ~
.platform_data = &da850_evm_tl_leds_pdata,! I* D5 K2 l- _: g5 O
.release = led_dev_release,2 R: k+ t. B9 Y; l4 q$ j
}
. V6 k- k. r+ G, [};
( W$ ~; _( m3 o0 l! F1 G& `' s! C% G$ H
static int __init led_platform_init(void)
6 P. v+ \7 ~" j{" G6 r9 n3 k" `0 F# @5 o# s, Y
int ret;
X" K; u: ]. u" T0 Q* p' w#if 0
5 K7 z( @& y2 x ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);" J1 D7 r2 M- C3 \
if (ret)4 v8 ?# N% u) J) U* J/ Y
pr_warning("da850_evm_tl_leds_init : User LED mux failed :". M/ ?5 }% b, T% w" I2 v$ C
"%d\n", ret);5 ^) s7 C3 y2 ^2 Q
#endif
! D7 Q) D& j6 V# @- s/ G6 `$ a5 t ret = platform_device_register(&da850_evm_tl_leds_device);% P; X& q& W n3 U
if (ret) K# Z) K6 A1 H
pr_warning("Could not register som GPIO expander LEDS");
" z( K, g- u/ Q4 z/ E/ P' } else
5 O4 A3 h- a1 E- Y5 Q+ { printk(KERN_INFO "LED register sucessful!\n");
8 }9 W+ s! z0 }+ I3 O8 [: R) L( i8 |' p
return ret;
# h' w. U3 @8 Z9 r% o1 _3 d+ F}# K5 d9 L) q) f; C% D$ l; O6 _' a
& _! X* j6 H \" t \$ }' S
static void __exit led_platform_exit(void)) w+ u% ^2 J" @: v, S; I2 a5 }
{
; M' N5 Z# v( } platform_device_unregister(&da850_evm_tl_leds_device);: B5 I! H) r$ b7 b: Z5 r; A2 p
$ ^: I+ i0 U; x* m, J) q1 I printk(KERN_INFO "LED unregister!\n");- X6 A. [( A: {. [. `. D
}
1 l; F) i" T# H2 T4 j7 Q s: c- r: r& w, d2 J4 w
module_init(led_platform_init);6 e# h5 k( D5 U$ c n' ?
module_exit(led_platform_exit);
1 E( T: E1 F6 j# J: o; V; ?
, g; {5 D3 S" u5 |4 e* y$ o& VMODULE_DESCRIPTION("Led platform driver");
. ?0 \: z3 u5 z5 s1 S g0 xMODULE_AUTHOR("Tronlong");6 K9 I! Y) z" z
MODULE_LICENSE("GPL");" `& O6 |3 ~2 u$ L9 g' n
9 S4 z( N' S4 \2 s% y |
|