|
|
求大神给下面的程序做注解,请稍详细些,谢谢。% G$ }" w( b" {& |
#include <linux/init.h>/ r/ u9 k6 [! S. X- m* S7 B# I9 u
#include <linux/module.h>
5 V w* j( I1 } c) q- ^#include <linux/kernel.h>
6 A% [+ W- t7 s. B, V! x4 X; q#include <linux/types.h>* s0 r: V6 H/ C4 U& F
#include <linux/gpio.h>
; [8 _8 H+ t* q& V% L/ ~#include <linux/leds.h>
5 m/ u: A0 F3 c2 c$ m+ F#include <linux/platform_device.h>- g. R5 S6 e U) L& D' m& v; x
: k, [ i1 J8 e6 ?% n2 _* h. o2 P
#include <asm/mach-types.h>, ]; s2 k1 y5 }% C; T0 D
#include <asm/mach/arch.h>
2 z( p5 Y+ h0 j2 `/ j# T* W#include <mach/da8xx.h>8 v/ o: X. Y. Z
#include <mach/mux.h>
2 _. w1 M6 I: G: u; |9 H6 i& a$ g/ D7 w- c
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
6 x9 y: L- u- T0 o1 F8 M0 m#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)) U8 ~6 C8 `4 _; w2 V" ]- l
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
1 I/ m$ M# i! Y w* Q" \+ h#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
1 `0 _+ X& g* E" g P1 L& d: n L- g/ x" J8 }% _7 y7 L" W
/* assign the tl som board LED-GPIOs*/
6 v8 m, v, V3 Kstatic const short da850_evm_tl_user_led_pins[] = {% @6 ]$ s+ A6 B6 o% f9 w
/* These pins are definition at <mach/mux.h> file */( Q K. \4 f: n, ]. V5 W: v1 [
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
( Y8 H0 z( X5 p1 [1 z; w9 ^ -1
" y: \3 c1 V4 c};4 s! g% b, \9 _8 U
4 w7 u2 K: Y$ s0 G& F! C+ b
static struct gpio_led da850_evm_tl_leds[] = {0 D l" u3 ]8 T( Y( ^$ j2 S+ Q
{
) z( r& Z6 h. R% l/ c2 ` .active_low = 0," M' {$ `/ |6 C6 u
.gpio = DA850_USER_LED0,
- F$ s8 ~# z0 j, F4 D .name = "user_led0",
j" E$ Q% j2 @! j .default_trigger = "default-on",
2 C p! O# @2 ~. w },
6 V/ N; V3 u$ R1 H+ `) g% m- h8 i {
: B' g, o3 [& B: |) Z: } .active_low = 0,
5 e. m8 D% U8 V0 B9 X .gpio = DA850_USER_LED1,
: S& r+ G# m0 u" u) ^ .name = "user_led1",
7 b3 J4 D& \+ t1 z1 T& b .default_trigger = "default-on",* n# \) E; a% p
},
) D$ d( t5 V4 G' L' }7 P {7 q. v9 }4 B" v( Z G; ^) f7 X" l& E1 h
.active_low = 0,
/ ]4 d" i$ g: `) Q* j: f+ K7 O .gpio = DA850_USER_LED2,0 j6 p% P6 k4 m, R5 X: R
.name = "user_led2",
) p5 }7 R0 r q8 U7 _ .default_trigger = "default-on",/ z3 f! [( {# c0 O! x$ B
},+ R3 ~- O8 W- P" @! ]" w
{
" c, M4 Y; D2 ^: }3 U .active_low = 0,
9 l+ s& D. J( ?% e5 R! I .gpio = DA850_USER_LED3, y8 l- K9 J6 s) ~. j: D. r
.name = "user_led3",1 T8 X0 k- O) D; O
.default_trigger = "default-on",9 B' {/ s: I" g) ~9 s% F i
},
4 _# Z! p8 \, N! i7 s};0 b, d, ^8 H C" q- s4 z. `! z
5 g# I$ U. S( Y' Q$ lstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {. @! D0 ^* d, [
.leds = da850_evm_tl_leds,
' n* R5 s: t v- L. [# O .num_leds = ARRAY_SIZE(da850_evm_tl_leds),% M. e3 R" d) K H0 f
};# G6 T3 {3 a" P0 H
, K/ ^3 H7 a+ O" y
static void led_dev_release(struct device *dev)1 ~9 Z8 t4 f, P+ k- w5 n
{
/ a( \) d. r9 Q" u, R! j};$ ] W+ f7 a: ?7 a
A. {' `: b" |' F; ^: ~1 rstatic struct platform_device da850_evm_tl_leds_device = {$ N2 g+ S' m% }: I* F+ M
.name = "leds-gpio",) Y+ u( h: A! c0 G0 }
.id = 1,6 ]3 @. T( S# d% V
.dev = {
7 `3 c; Y! k" L8 V8 o' R8 u1 K" ? .platform_data = &da850_evm_tl_leds_pdata,
$ _! C1 L/ z" i. u; b .release = led_dev_release,
5 i1 w3 A/ ~" K' y }3 }" Q }" o' M w0 F
};" j0 s- J6 m( R# i; C# v5 r: Q# K3 R
( h: m) s; q) z6 @. O7 ustatic int __init led_platform_init(void)' l! l& ?! K5 P( Q
{
4 ^' @: l8 l, |, p int ret;5 d( r. g/ k* f! a
#if 0& H; n2 ]4 }. L" j' I: L3 g5 s
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);0 I; R9 w; P0 R# F5 @* u
if (ret)
1 ^0 B! h) b& v& d0 h2 X pr_warning("da850_evm_tl_leds_init : User LED mux failed :"- l/ m$ ~/ l8 u+ ?% f; W& d1 o
"%d\n", ret);2 z+ w; B- R$ o0 g
#endif
! }: Y) X8 F' y ret = platform_device_register(&da850_evm_tl_leds_device);1 w; Y7 A6 ]* |! @7 Q
if (ret)
0 F+ R% Y, {, P% k5 K pr_warning("Could not register som GPIO expander LEDS");! M/ H5 l+ T5 G
else5 b3 o/ a8 h4 P& e+ u1 C- X, {* X
printk(KERN_INFO "LED register sucessful!\n");
b" z H/ O) \4 s/ U9 m
2 G' \$ p. P0 Z: C: ~ return ret;
; {; I7 p8 h" k/ Y- L7 P}
: @- B( b* w5 Q6 s! u9 g
1 t: _, P4 {7 M6 |1 Kstatic void __exit led_platform_exit(void)' R5 B7 {9 O% d/ Z7 b5 k# I
{$ I, Q! w: h9 Z, Z/ [# j
platform_device_unregister(&da850_evm_tl_leds_device);% O! \+ A$ k5 ~# G) H' z
# D5 `1 q% O# `0 [. C% j2 I9 Q" a8 T printk(KERN_INFO "LED unregister!\n");9 k2 a+ M I$ F6 u# D6 H6 e
}
; [/ X5 k( p9 h3 h0 K. g
6 |3 r2 h' p$ i, D5 T' |module_init(led_platform_init);
7 b, c* C$ p/ q" {7 emodule_exit(led_platform_exit);* I. n2 X1 f3 D/ h4 o$ w% x4 x
( Q- {1 y3 H% p, Y e8 zMODULE_DESCRIPTION("Led platform driver");- N: }2 [- g9 i$ b3 [
MODULE_AUTHOR("Tronlong");
/ _& [& B1 }' r/ G5 _MODULE_LICENSE("GPL");$ |3 C2 P( {! }# Q7 e P
. P- k# t }1 h f |
|