|
求大神给下面的程序做注解,请稍详细些,谢谢。2 b4 d5 w+ G X
#include <linux/init.h>
1 E Y1 a/ K0 }: j! W" Z9 q r, {#include <linux/module.h> ?' y+ c. Q! g" }& D" K# ]
#include <linux/kernel.h>
1 ~9 A+ w! X# N#include <linux/types.h>
9 O* R' [5 ]. [#include <linux/gpio.h>) Y% I; u7 g/ M: w
#include <linux/leds.h>! J+ Z) T1 e/ U2 ?( u0 o
#include <linux/platform_device.h>
9 l S3 I0 C) U) C/ s' q$ m; v$ N
#include <asm/mach-types.h>1 R+ g- V1 j! z3 t. w4 b" o
#include <asm/mach/arch.h>
C, ]$ m: h% o, R1 g2 s' h#include <mach/da8xx.h>% I/ v0 S- x. H% V- H
#include <mach/mux.h>
4 Q8 `0 Y2 j6 |8 t$ {) L6 B, c- \2 V* n: P' k4 y
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)% U4 V( t! n3 G( `0 B; \' R& e! I4 z4 u; \
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)7 M4 g7 Y% j) u4 z
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)0 A: l" E' O' t$ e
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
, O% O; P8 a+ t4 [6 A) X9 N; h
) x( H. M! h5 l) d* h/* assign the tl som board LED-GPIOs*/" ~! D2 \, l! i0 [) v) A5 p2 k3 C) }8 C
static const short da850_evm_tl_user_led_pins[] = {
$ ?: q( u; \9 h7 u8 D" E' a /* These pins are definition at <mach/mux.h> file */) U7 b0 W0 W( b$ J+ [4 V( u5 {
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
, l- n6 \! g0 o9 j- W0 z -1
3 N9 e! c2 p+ M};0 S- M0 s! ]! V0 p$ |& k
( P4 r3 @5 T5 }1 gstatic struct gpio_led da850_evm_tl_leds[] = {2 U m3 L6 l' b7 D
{
4 l$ m& U1 ~( Q5 x# `- p% Z+ }3 K1 e .active_low = 0,7 }' ^+ J! C# s; B1 f
.gpio = DA850_USER_LED0,$ B& P# Z% p& N( n
.name = "user_led0",6 V5 B. U0 \, |
.default_trigger = "default-on", u# e7 s" T( Q- N# ? u5 M8 s/ N p
},% b3 D; L( {+ Q' j8 F; A, f
{7 _1 z, C5 W, C/ Z" D
.active_low = 0,
$ e* r4 L) [6 |+ k' G* Y1 R .gpio = DA850_USER_LED1,5 b: |+ \2 W" E
.name = "user_led1",
- n7 z D, {* A( Z% q! v .default_trigger = "default-on",; v3 G/ G0 Z6 p
},- P- l% s# w: O( [# u
{
2 O, S. h T* I .active_low = 0,% W# B0 b+ N9 O# d `* h, J. a
.gpio = DA850_USER_LED2,
' c/ o5 K5 G- j0 ?/ O( e .name = "user_led2",
" q9 f( x. _% r .default_trigger = "default-on",% E% e5 F4 S: i+ g3 y) z6 x1 Q
},
# [' v# l1 l: T {9 D+ R% t0 a5 n5 a* ~& q1 _
.active_low = 0,( D- f3 i0 S3 U: T6 o( u1 F
.gpio = DA850_USER_LED3,) l# D( `& E* U% y& u
.name = "user_led3",
$ b7 t3 i8 y% ?1 e .default_trigger = "default-on",
( Q) }* d& I# f& i },
E5 p$ m9 z- l. C2 t6 s# f};; B n) H( Q, ~0 a- _
5 E9 k. Q' q N. e- F- z5 @) i
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
% v! U8 B- x6 w& _( I .leds = da850_evm_tl_leds,, {3 c' H$ X2 w+ J" M. `8 X+ X+ [3 w
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
# I0 L6 a' }! l; `. r6 y1 J* q};
6 b9 T4 D' K9 P9 v6 ^' _1 U# a/ \5 V! W
static void led_dev_release(struct device *dev)
$ m3 Q( n4 S6 T5 f2 k8 F3 j( p{
. ]9 g8 N* K& m2 G e};- Q3 }* T; [/ Q6 v; C3 i/ Q/ M6 e
3 x( L* f1 H- |static struct platform_device da850_evm_tl_leds_device = {8 T& g) U1 \1 G8 x1 ^/ Q
.name = "leds-gpio",
6 V# q9 W' _6 |, o .id = 1,
6 ?, x8 p( j/ o) y4 f2 t& G .dev = {. }! r6 T8 B: S
.platform_data = &da850_evm_tl_leds_pdata,
# n+ `1 w7 ?0 U# _* w1 f .release = led_dev_release,
: Q; y; e5 i8 \6 x/ F7 G }
, I6 C" z8 N* f3 [};, g! @- { m0 W+ q- \( c: `. w2 X
# y4 }, l4 ]* y+ q6 S% Z) K
static int __init led_platform_init(void)
$ H7 g. \+ x& g3 l{6 H& _7 f' Y$ W% ~" W
int ret;
5 q4 m Q2 J$ F: L! V6 w' a#if 0
1 n) K. q4 {( I3 ^- Q ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
1 O8 ~, j6 Y2 L. g if (ret)/ Z2 i! z' c) T1 v. c6 `
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
2 {; H- X( ]; W1 |5 p! D "%d\n", ret);
4 M6 H" ]5 g2 D- Z#endif+ [/ \2 ` Y6 ~6 D% y
ret = platform_device_register(&da850_evm_tl_leds_device);
% j/ O) W9 O D3 A% ?% b% P- @ if (ret)
; _1 V) Q$ C2 O0 }8 z5 e) _ pr_warning("Could not register som GPIO expander LEDS");3 ~" e/ E$ o8 E, ]2 y4 v1 E
else
6 k2 m" ?0 Q5 U1 M7 [ printk(KERN_INFO "LED register sucessful!\n");
6 q5 ~, j( L K: I
" x. g4 S( z: h1 b. {( |! M3 a' x return ret;
9 ]0 |7 O$ p& t ^. O}8 s, P5 D# c \4 U3 K- t; z2 L+ V' C
0 {2 a7 D+ V$ q" m* L$ r
static void __exit led_platform_exit(void)
& `/ ^8 o. f- E+ A& g \{$ `$ C9 ~+ O) Q$ d7 y0 Y
platform_device_unregister(&da850_evm_tl_leds_device);( i- l# [. r* h# v
; L7 @: f/ z0 J/ t* o: U) z$ o# w! i
printk(KERN_INFO "LED unregister!\n");0 n# ]* y( B, ^( x% _0 K/ S, x
}6 Q) U; _* ^. ~9 \5 _- s
. M# P+ |/ Y! z6 x
module_init(led_platform_init);$ `$ z$ ?! [$ i9 b) \. Y
module_exit(led_platform_exit);$ P- g) F3 c1 E
% u+ E% n7 A* [& W
MODULE_DESCRIPTION("Led platform driver");& J$ Z$ ^0 _3 K, L6 D* Y4 ?$ q" ?
MODULE_AUTHOR("Tronlong");
# S- P6 F! ?4 g4 uMODULE_LICENSE("GPL");
. h9 L, J2 m0 g) Z/ m) {- O8 B- j1 I3 H8 @, W& c+ \
|
|