|
|
求大神给下面的程序做注解,请稍详细些,谢谢。+ {# x' F; Q, w2 l' n4 I: I
#include <linux/init.h>
# K: x8 ~. N* c6 u6 V% o#include <linux/module.h>) Z% ] _* I {0 l0 L7 D6 b- ^7 _
#include <linux/kernel.h>
2 m; {9 X ` V) h#include <linux/types.h>: O1 v2 x" ?; d1 W* V& @
#include <linux/gpio.h>
5 g' I6 k, R6 K#include <linux/leds.h>- ]0 H, g& z3 U
#include <linux/platform_device.h>( t" T' ?0 m: `* k, x# I& [( G$ ]
3 v# G9 N$ X, v8 a7 L! ~#include <asm/mach-types.h>
1 B4 w: |3 f) I: Y3 L7 d) b7 o#include <asm/mach/arch.h>
k7 D! l- ]7 w( Z$ V- Y#include <mach/da8xx.h>
$ J4 K' \9 ~# M+ ?#include <mach/mux.h>6 l J+ Q# R8 R1 Q, @6 B. j2 M3 M
9 `8 ]# u- |3 h; l
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0) j6 l, W) M( J& s5 n
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
8 l, Y& Z8 m4 w b; ~& D' C4 ]#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
' {, {% G1 }2 x% A$ {* ^#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)4 K4 ], ^7 d9 Z5 A/ u& [
( X% \2 u1 a* w7 x/ ^) r% X" v/* assign the tl som board LED-GPIOs*/
/ i' ^1 O- D Hstatic const short da850_evm_tl_user_led_pins[] = {
0 M: z+ _4 }: N+ Y" z4 g! A9 O /* These pins are definition at <mach/mux.h> file */
7 F3 X+ j3 M% w+ @ {6 h DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,6 u4 R3 d/ b! t6 u! r- {4 n
-1/ i: c2 b) G. e2 p# h
};# y8 {1 s& |6 q5 f3 I0 c) a/ ~4 W
5 H1 C1 W' ]# b2 k' A. R5 wstatic struct gpio_led da850_evm_tl_leds[] = {8 w( V( C1 ^$ q7 d# q9 ^/ W( x
{
% T9 ~% @$ B. k1 ~ .active_low = 0,& }. \, Y9 b H+ D6 a& G0 ^
.gpio = DA850_USER_LED0,
l; `: s7 ?" m' M* U/ C {7 J" o .name = "user_led0",
! I1 I+ E' U: v2 Q .default_trigger = "default-on",. w: X) D% i6 g0 z2 }: {6 P/ f
}," w" @( f# Z' j& U. v
{
5 ^! c M' v' Z+ B6 t6 z/ p( M .active_low = 0,. {; S" w2 d) W" o$ b0 h8 J% o
.gpio = DA850_USER_LED1,
* S4 r; B0 |- E6 \1 k) e .name = "user_led1",
6 q0 N1 l" _, k! }$ b .default_trigger = "default-on",
/ |! ]. C, i5 A9 d% n& J! \ },
! x! ?8 Y1 K: A6 d( { {
& Z* g% `' R; B- q3 X4 X$ C- W8 o2 L .active_low = 0,3 S" g- s- v/ P+ u: a: l" V
.gpio = DA850_USER_LED2,
" X, Z: r( ?+ v7 j! v) y .name = "user_led2",1 U5 A2 l. |- c) f% Q
.default_trigger = "default-on",
) m6 i1 Q1 r* A" _6 H1 {: E }," j. s+ v; ?% B& R
{! X5 F7 d7 E6 A( p4 T D3 v
.active_low = 0,
# B/ k/ Q% f ^$ m+ y5 o .gpio = DA850_USER_LED3,
! b# q+ B1 P& p6 E .name = "user_led3",
0 R) r9 T7 y- c .default_trigger = "default-on",) D* H) M- V8 ~/ C H9 x* i
},9 t2 A1 _) V2 A$ X) @
};
6 V7 ^, L" Q" \( t& C" C. q! b
# X; ?4 D# t' s) l$ K/ Ustatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {( Y& o% }3 s8 \- i
.leds = da850_evm_tl_leds,* e$ j* N* i( @: ^; z" X9 z! [! [
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
2 |& r3 S" @* h! c/ f};+ }) Q3 h( X4 M) @; Y0 C
, M& g. N; r* N( fstatic void led_dev_release(struct device *dev)
3 |1 k! M9 E9 { b5 k) I$ O{
; r6 N: y& B$ M9 A+ D ]( X: K};+ i% h) `, F3 q4 X c* X' g
' A+ I1 T+ g$ m/ y0 a5 Pstatic struct platform_device da850_evm_tl_leds_device = {
" O& X9 [& s% V# d7 y% z7 i* ^ .name = "leds-gpio",
, R" f* J# z$ Q6 u9 g j! _7 v .id = 1,1 [( h* D2 R$ @! t9 d# t7 G
.dev = {
+ ]2 |, }# [, C$ R. L .platform_data = &da850_evm_tl_leds_pdata,
- j( D4 W) M4 V) w2 {! M0 m .release = led_dev_release,
. U8 m8 ~2 M* l0 K0 _- N }
6 g1 Y" ]! F j5 o% n}; [# \4 ^. K( Q4 q
/ l9 K0 ], J. J3 vstatic int __init led_platform_init(void)
5 P7 x/ J% ~' l; U{3 A! s" h+ q2 [
int ret;
# N% X# Z& |( f- e. W#if 0
4 ^; w0 x: V2 @! Z( c ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
! s) e& `9 K2 ?6 l" q if (ret)' V: i) V( s9 f( `& n. U' T
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
, x3 i3 L- |& f. {8 T" m "%d\n", ret);, G# y" m, g3 q% K
#endif5 D6 T3 X- S/ ^; V# @5 T, G
ret = platform_device_register(&da850_evm_tl_leds_device);
4 I" f& L3 a w if (ret)
( s$ y* {2 T" M; Q' z( J9 e pr_warning("Could not register som GPIO expander LEDS");$ k. C/ w/ R2 r' O7 b0 n0 a8 }* Z( S
else
) k* R. a7 ^2 ]! i printk(KERN_INFO "LED register sucessful!\n");
8 N* U% {. z O* J( S# F1 r$ \) a# r; K1 h
return ret;
0 C3 W7 _) P, Y$ U& \- q}
4 \6 u9 C& X$ O+ n3 \! F& l3 P, Z' P5 A( ^
static void __exit led_platform_exit(void)8 z1 i) c# g# Y& g
{
0 e( L' C# f1 b+ ^' N* N/ j& W platform_device_unregister(&da850_evm_tl_leds_device);
& E" ~4 r1 m4 ~4 t$ z$ M R5 d" M6 V
printk(KERN_INFO "LED unregister!\n");
6 g' h+ l) v2 b& W0 K6 T, j, F}6 P3 ? g$ k% y d1 D6 ~" A3 l
: S2 N: r4 n& s6 c! D, M, Fmodule_init(led_platform_init);- T3 H" v/ X4 W9 n
module_exit(led_platform_exit);
( e( x2 ^- w2 n- t+ v0 `( D
, H+ ` ?9 A3 NMODULE_DESCRIPTION("Led platform driver");
5 m3 c* ~" C7 z& l2 E& FMODULE_AUTHOR("Tronlong");
$ i$ F0 Q3 m* }2 y* g# a! gMODULE_LICENSE("GPL");* s& G" k+ w3 E1 m% Q7 X% Y
1 U* C) V! L+ G& Y% e7 ~
|
|