|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
- d: z& c* d1 x2 N#include <linux/init.h>
2 Y: I4 D, b2 T6 Q' `#include <linux/module.h>
4 J# ^0 m0 G; s' j% K#include <linux/kernel.h>
- j9 ~; n) y ]$ R, q) b$ E6 H#include <linux/types.h>8 m4 n/ s( A2 F- h+ V9 q$ v
#include <linux/gpio.h>
) F) o0 o I ~4 A! U5 y#include <linux/leds.h>( p8 b# c- V E2 b
#include <linux/platform_device.h>
. r9 m; P h5 ?+ p7 C
" j* y7 M# D. q#include <asm/mach-types.h>2 a' {' x, K9 U' L5 F
#include <asm/mach/arch.h>
& m* \8 y* I/ c7 b& l; i$ }#include <mach/da8xx.h>9 y$ ^* j) e9 F0 V" R$ P
#include <mach/mux.h># t: A' ]7 Q* q( S R/ k; R
0 {& q* g: D% [% L: }5 A3 W#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)2 b; d7 G. n; `4 R9 k/ P2 q& U) y
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)+ g I& t- ?& |; \; K. L
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
, x( X9 g6 i1 s- e1 y1 X4 A#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)2 E, X& g5 a! q$ b _; V g+ f: ~
) n& j4 k; A8 T/* assign the tl som board LED-GPIOs*/% R$ W& @2 o; \" H# {; h0 ^; }1 X
static const short da850_evm_tl_user_led_pins[] = {1 |% x/ x# v/ F
/* These pins are definition at <mach/mux.h> file */ v+ g. C$ n/ K" D: Q" m% d: A6 y
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,- |& ~& Z! @5 s! f; v
-18 w1 N0 K4 U# j
};
+ C3 E4 `5 [2 ]" |
+ k" E/ E1 Y' f9 K0 B. Estatic struct gpio_led da850_evm_tl_leds[] = {, T, z; |9 u9 \
{
' ] L1 P- q5 B& F7 X .active_low = 0,4 I, k! @# t8 s8 [! A
.gpio = DA850_USER_LED0,, R, [" F$ B0 u1 F$ t: i$ B
.name = "user_led0",/ c! J; g+ D" m4 M% ?7 z
.default_trigger = "default-on"," K. X. A" p/ q
}, K1 o4 O! j; ~! M$ |& g% H' L" ~
{. W' u; Z. P: J. H% E
.active_low = 0,
' ]2 ^4 U3 a7 F+ _" c .gpio = DA850_USER_LED1,9 U1 O3 F% h; s6 r* g3 y) U- l+ G
.name = "user_led1",
0 _$ k- h) _/ w* o, C .default_trigger = "default-on",
' s8 W3 K8 r6 L! @ },
" i9 U! s2 }. D, `$ S {8 b3 n+ O# E/ f* k) q
.active_low = 0,
. r' x* m' B, z4 i) P7 v .gpio = DA850_USER_LED2,
: ~3 v# j7 S2 z2 q& A& ^( e .name = "user_led2",' m% q& p' E: f- g
.default_trigger = "default-on",
8 @% x( x) [/ W U1 g },
& O2 t, j0 C& F6 ^; @5 t6 p8 J+ x {
% x! p- a6 v u& ~8 {9 Z/ X& o .active_low = 0,- w! t" R. w. x2 x" z" @3 i
.gpio = DA850_USER_LED3,
3 O9 _/ [ D" [$ H2 d' {* d .name = "user_led3",) ^7 z4 G3 M- s( a
.default_trigger = "default-on", y9 `8 K/ E2 t3 |+ i$ c2 `
},0 ?0 r8 }. t+ Z) B4 O
};4 n0 R5 l1 t/ F
2 n/ I0 y+ Y2 O' n( m, t0 N" l
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
* K# n$ x; y n/ x) g& { .leds = da850_evm_tl_leds,
1 u5 O+ g. P4 y/ |8 K .num_leds = ARRAY_SIZE(da850_evm_tl_leds),( ^5 m# ], P2 m u* J
};
; U/ R$ P3 u5 z2 C$ [3 q& v& Y) }# n# T$ M+ B% s1 M0 f
static void led_dev_release(struct device *dev)2 S ~; A m' K8 n4 m
{
' E# O8 q" j# _};
) P1 g) i$ d0 O5 [$ [2 I
; u0 {# G( a! c! i7 C0 hstatic struct platform_device da850_evm_tl_leds_device = {
; h# p5 }" B1 ^% Y6 x I9 H .name = "leds-gpio",/ B F+ F' w2 a+ f* B5 X
.id = 1,% s k" ]+ G6 j& E$ i
.dev = {
_1 K4 y0 b, |6 E .platform_data = &da850_evm_tl_leds_pdata,
) K+ @: L% w; L( c3 P .release = led_dev_release,- I7 ~, e' ^" d/ B7 ]. I% ~- E
}$ `- z; J% P3 t' v' c: ~
};. O" j6 _; c4 N9 c- Y% k- o
k7 ]/ A! M3 L1 G g# P8 B
static int __init led_platform_init(void)* Q- g# c" j+ Z: W, z# f% T
{: B; Z. n2 p$ ~2 d. k8 J
int ret;
5 t' Y6 a$ N n7 M' k0 h1 }#if 0
4 t; ~; J+ p2 A ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
9 ?) e: n8 Z7 ]' m if (ret)
7 w5 c; I4 q6 a4 S" a7 G pr_warning("da850_evm_tl_leds_init : User LED mux failed :"+ i- {! m; S6 |) f) _* }2 a7 L
"%d\n", ret);: N$ R8 _/ q* B+ N: ~- X# B
#endif
2 s+ F: r' [2 k8 x- {* P ret = platform_device_register(&da850_evm_tl_leds_device);
; e# N* G2 q7 E5 O. S" G V if (ret)
4 m) o! [0 {& e9 Q' {; u pr_warning("Could not register som GPIO expander LEDS");
$ R- W8 m8 ^) T' L4 _/ { else
8 x4 y! B- P- ^& v1 I printk(KERN_INFO "LED register sucessful!\n");
" e( m+ U% d+ C- w( e" d( [" V& }" K9 B8 ^( G# W( f5 s6 _8 J
return ret;- C$ A5 M5 f% }1 W. X
}
4 Z; ?$ ]4 y/ j) g& c
$ V x5 W8 y2 m# Y% n' Xstatic void __exit led_platform_exit(void)
, G& \: [ m9 |) ~{/ [0 [4 w* @& {* Z
platform_device_unregister(&da850_evm_tl_leds_device);+ F e' M% `7 L' h6 p
5 T9 ?3 ` [3 \7 N
printk(KERN_INFO "LED unregister!\n");
% r5 N6 B1 i! i3 `+ f}
! N1 h5 q2 I3 z g* x( S- h2 n Q: o' v" U) n% o
module_init(led_platform_init);3 Y4 Y3 g- _ a X8 I
module_exit(led_platform_exit); t1 o% J4 y& d3 ]; H, p* T" N
1 i7 R; d1 l, @# mMODULE_DESCRIPTION("Led platform driver");! @3 k/ N' _; y& d- V# q
MODULE_AUTHOR("Tronlong");
+ Z# k9 ]" f% ]. K' d6 HMODULE_LICENSE("GPL");* C3 t0 b- k9 t u4 T: @1 a
3 l- l2 M5 M5 c; @5 F
|
|