|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
) N8 I% p+ D4 G. \: E- k- ^% E( E#include <linux/init.h>, W' s G( n- q" ^* M5 X( K0 d `
#include <linux/module.h> x6 ]4 @9 F# O5 X
#include <linux/kernel.h>
) m% W/ f; E- l4 E, b1 b+ ?#include <linux/types.h>" e- i' ~2 C# `7 H& k
#include <linux/gpio.h>
- d$ S8 s( g/ l }4 f$ l& a _$ p#include <linux/leds.h>1 N/ y* x6 m) V$ t! \
#include <linux/platform_device.h>! J. N( s! {5 J+ t
3 i+ c P0 i* s4 k1 u
#include <asm/mach-types.h>
3 p3 |8 u% q4 R5 ]/ ~- B( w#include <asm/mach/arch.h>
2 X1 G" {+ p9 c) G/ k. ?#include <mach/da8xx.h>1 c6 y* x8 Y6 _' h& E$ h) q, s& f
#include <mach/mux.h> ^! E+ ]6 t+ o4 P! ]2 b( V8 j8 O
; P% `6 y6 J3 T6 r5 W) ?#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
5 {1 F! L$ K8 A. H/ Y, N#define DA850_USER_LED1 GPIO_TO_PIN(0, 5). O5 v" u% Z9 ~0 e
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)0 Q% C( P% I$ W2 ]2 e
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)/ ^ \3 ~5 C% r' ^% ?4 ^
. {( M* h4 Z5 l3 M! Q! f/* assign the tl som board LED-GPIOs*/
( W6 w) `( s' Y% vstatic const short da850_evm_tl_user_led_pins[] = {* a: G5 T: G5 {- M, w( q
/* These pins are definition at <mach/mux.h> file */; F% P- {! ]( a7 U# S
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,$ j2 \: S* t* d' C/ D
-14 {7 c b `! ]
};
. I4 q0 V2 I5 W! x) X& P; k+ `( [1 P* J$ N: V7 k1 V- o; o( Z
static struct gpio_led da850_evm_tl_leds[] = {' V" }; Z, j9 ~6 a& R7 h
{$ U* W$ H) _2 e3 I- R
.active_low = 0,
1 U. T& d: t2 M' q- c+ `; E0 i+ ]( q .gpio = DA850_USER_LED0,) }0 w4 w m6 T, x6 g8 B% i; s l
.name = "user_led0",
: S. ]" j0 b2 p: d- Y( F; e& d5 | .default_trigger = "default-on",7 {0 ~; \6 k# e8 y
},
" K5 c7 V- Q. z7 i+ I. t6 j {. |2 y+ T) O F6 |/ q
.active_low = 0,! {, F! @; ]2 Q
.gpio = DA850_USER_LED1,
' z1 Z! N: A6 _" x0 g; Q .name = "user_led1",
: j0 ]' E$ l8 e5 P& y! L% w .default_trigger = "default-on",: l8 N6 U: m+ D( i
},8 K7 G0 I8 \7 I
{
# L- u! M3 i9 u1 F( M" P* s .active_low = 0,
7 v' n- ^ b- o/ z3 p7 z .gpio = DA850_USER_LED2,
9 Z2 x% @. |3 u: B .name = "user_led2",( U p1 O% ` _
.default_trigger = "default-on",
# M3 s; o9 o4 S2 K4 J },! x# K. s- u' ]# z6 ]
{4 a: {& {; y; g$ [& _- M0 ^& m
.active_low = 0,# i8 E- `8 i" u* C1 ~2 `
.gpio = DA850_USER_LED3,' p* S' a# H8 m* g' T
.name = "user_led3",& _" z. }6 {) L' f0 C; Q& D/ z9 g
.default_trigger = "default-on",
6 d/ _: d5 T& E6 }% S },; i3 M6 ?7 f! f
};! Y6 A$ i/ n0 Q' l: {
1 ]" g2 ~7 b) L, ?4 O {static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
3 B. `$ s4 F9 k7 a .leds = da850_evm_tl_leds,
! `) N, B! |6 h: x5 U3 x$ S: |. D .num_leds = ARRAY_SIZE(da850_evm_tl_leds),2 B5 I [: X! l$ R" {# D& S9 \4 E
};
5 O- f L) d6 ~9 ?- ~! C! S
* [& k# r! t- {9 _$ Xstatic void led_dev_release(struct device *dev)
( i F# U7 I! O+ c1 A{
1 \8 e; d( u/ [ N/ \};& V9 l9 S5 W6 }7 C; |3 G% o' s% K
% J6 U! x- \; T( G$ P/ {4 w* Wstatic struct platform_device da850_evm_tl_leds_device = {
; y$ E# {4 _+ P/ s .name = "leds-gpio",
5 {: R, ^2 P% |- ], E .id = 1," w: d% y+ b4 V2 k4 w
.dev = {
" |, n+ m/ d8 J8 u) c .platform_data = &da850_evm_tl_leds_pdata,; n5 G+ c/ S9 a2 v; L B5 E
.release = led_dev_release,
; K, e- c. G" f4 Q6 m; v: u }
) M' U$ q5 \6 c1 r: ~& s6 {5 ~* N};! {) Q' ^ Y1 A! g0 g4 R1 S! @
' N: p1 }2 K; Y7 e: I7 q
static int __init led_platform_init(void), o3 |. j, s# C: Z3 N6 x
{
) ?6 Z" j s( a6 T0 f) l0 x int ret;; L- k6 W( j+ d$ O% S
#if 0
+ |8 [* h- Y d! V: I6 x" k0 Q ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
# i {: {# V& T. l if (ret)
$ j& r! K* l) z# |0 u; Q. L3 d4 D pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
+ Z8 v. P9 Q o+ C+ V2 d H "%d\n", ret);$ b6 u* Y S3 N( [) o& D
#endif
# _1 Y3 V( J; u4 X ret = platform_device_register(&da850_evm_tl_leds_device);- ]; O" M" s: z% c4 Y+ J
if (ret)
& C# W3 M( i% r4 c pr_warning("Could not register som GPIO expander LEDS");( O, q3 n( B+ {- s& l. o* W
else
' ?8 m9 m+ S4 }- U+ o2 g6 s7 O printk(KERN_INFO "LED register sucessful!\n");
% l g. ~# i( X8 q
' \$ z! E+ z! }% D return ret;$ A7 w$ h& Z- @- l( @2 g/ m
}
, L+ v: @5 r) c6 j) P
# j# |; }) s; kstatic void __exit led_platform_exit(void)4 N+ u& l* x6 `( X1 ]; a
{
' ~, \) }. ]8 p4 I1 I* h" ~/ N platform_device_unregister(&da850_evm_tl_leds_device);9 t/ j' e8 X- _; P, N' T
3 _' ^8 I% c2 {8 z8 N: o1 R
printk(KERN_INFO "LED unregister!\n");; m7 {( @2 |/ p0 j6 P d
}
9 d& I5 s0 f: E, k' n7 T i$ |
) t/ c0 Q! o! `( J; X8 _module_init(led_platform_init);! i7 }+ t& _* O% M$ x& Q
module_exit(led_platform_exit);, `8 p* w% V5 L" q
0 [" q8 K% A( s
MODULE_DESCRIPTION("Led platform driver");# a5 l7 X5 X6 a9 J S' ~
MODULE_AUTHOR("Tronlong");0 Y) B7 ]) D$ T8 b. ]
MODULE_LICENSE("GPL");
* E$ E+ a: t( ~& B1 m7 j
9 \3 V( S$ e' l9 K: m3 L3 e( Y |
|