|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
9 m. x7 f# y* o+ u1 |2 f#include <linux/init.h>4 I0 P2 u y: h
#include <linux/module.h>
( U# E% Z* K( w7 Q* |" K+ @+ I. x#include <linux/kernel.h>
& A( a9 @6 P1 m#include <linux/types.h>
' Q5 s1 E8 X( X#include <linux/gpio.h>
V& {; [: j6 d/ ^#include <linux/leds.h>
& G3 \7 q8 K# x% z) |' K#include <linux/platform_device.h>/ J7 I( I. {; _. B* Z" d
5 d4 o, M1 O o3 s
#include <asm/mach-types.h>$ W5 Z" [7 T( N; a
#include <asm/mach/arch.h>/ Z2 i. E/ v4 p# A! M3 n
#include <mach/da8xx.h>
8 _( {3 E2 E# ~1 B* I# O9 E#include <mach/mux.h>( ?2 r2 n+ h; ` A# W1 Z
# b9 f/ B6 }! w) j1 U0 W& }! I#define DA850_USER_LED0 GPIO_TO_PIN(0, 0), ]. M) a2 A* ?3 l. T
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)# J# K* p2 j. y, ]% p+ b% x0 ~2 m; S
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
1 M% Z" h% D5 `#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)' }! _3 {' d1 V: D. U& g6 Q6 d( t
$ j1 f k+ x! y' _9 F) R
/* assign the tl som board LED-GPIOs*/
5 i _8 O. a& V+ m6 }* jstatic const short da850_evm_tl_user_led_pins[] = {
6 X" ?. H' @* M) ~/ E, S( @3 w B /* These pins are definition at <mach/mux.h> file */- C( q$ O0 \) W) o7 [* \. z
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,2 P0 ^( L" o+ F
-1# i8 k' ?* u: l6 f, o
};/ c# z8 p0 |5 V& c, s, C0 d
! v: g% G9 |+ ?. }# Kstatic struct gpio_led da850_evm_tl_leds[] = {
' p5 y! Y. ?& L {/ Q$ K {
+ k1 n7 _1 a0 v4 E) E$ ]3 [7 |2 a .active_low = 0,
7 B5 Z K6 E$ Y: [ .gpio = DA850_USER_LED0,! s- j% ]% V8 T2 G
.name = "user_led0",1 t: C& A! V! k- I5 s& y7 @7 y
.default_trigger = "default-on",
, V- g- P! r. k5 N, q8 s" u },, F/ G9 T8 O, z6 e9 l) m2 k' b T
{
/ ?/ A4 o/ }- I: w6 T4 }+ F& ~ .active_low = 0,4 _$ f& |- L( R) P9 a9 o, q
.gpio = DA850_USER_LED1,
' e0 Z4 j( J% m9 N* ]1 _ .name = "user_led1",3 Y. }/ ]1 E: n2 ` a
.default_trigger = "default-on",
- q) M# F H7 W. R4 d4 j( j/ L) D },7 s8 R9 N w; ^* p9 G
{% C3 n" R2 p% {
.active_low = 0,
! t ^8 V, J2 H* a9 p1 e: v .gpio = DA850_USER_LED2,
. B6 O* w. ^0 X4 f! u .name = "user_led2"," Y1 P7 U" h$ F; V2 W* Z
.default_trigger = "default-on",
E" L1 S8 y5 B+ ~. d- F3 O4 j8 C },
, z1 a- b/ @% a% ?; A' E$ x# I {
" P- p9 a9 D. }/ R .active_low = 0,4 H- {3 `; ^1 ^' J7 o6 X6 I" @
.gpio = DA850_USER_LED3,
5 f0 ]& x8 S. t' V; E d- X4 B .name = "user_led3",* ~' ^2 l/ g! Z9 ~4 ?, l1 i) w1 q
.default_trigger = "default-on"," ~" n5 c5 `) F" M) E( Z
},
6 q( X+ ~2 H! l! W/ A% g: i' o" _/ |};& r( a8 C) G, `# }) A
& G/ J% N' O( l
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {' t6 V+ |! n z# p# q+ [4 c; q" W
.leds = da850_evm_tl_leds,
+ _2 Q: A. e7 {, |6 k0 b .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
, @6 m. V* O' m};7 F X( y9 r& K1 Z, x/ }2 C! e
' e1 M& N r8 T* l3 d- b$ p
static void led_dev_release(struct device *dev)
% A* f) t" U0 t4 j{
3 R6 w& Z+ c0 B0 ~/ y$ t' a};
/ R! L2 T4 i/ m8 Q" N. J2 s; z. {/ i
& f! l: _* T; C2 n$ d9 s* S2 Kstatic struct platform_device da850_evm_tl_leds_device = {3 M3 N# j7 O4 I) F6 E; O
.name = "leds-gpio",
. y! {2 k( _4 v+ _0 h0 u .id = 1,
, J7 X+ k! ^: C" { .dev = {' b2 o, u0 S- i7 H
.platform_data = &da850_evm_tl_leds_pdata,
+ D2 j( r& f, u9 s2 V& K .release = led_dev_release,
# M. ]4 u, L) o7 u: { }! `0 c+ Y( S' v* k* T
};' }5 ]0 D* r& Q( M; L# {( \
5 q6 e9 O- W) ]: z, t! Ustatic int __init led_platform_init(void)9 B7 B& T$ ~! A1 I
{
8 _! Z9 p4 l2 X1 L: s3 u int ret;3 b( O$ d( G& `; M& H! r" O
#if 0
5 z% t" J" V& S ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
( _3 I! H) l, {1 d5 {; Q if (ret)+ z: g7 M `6 f& H$ |
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
- {3 O# F$ |/ G; K: ^* K5 G8 q1 P "%d\n", ret);
" |+ d- I5 ^# Y" D4 p#endif% t2 F+ P9 h. m% P4 P) ?
ret = platform_device_register(&da850_evm_tl_leds_device);3 T( @& {; {( |2 k0 u& r/ `
if (ret)
9 b: ]: O4 C" U) J6 n& r pr_warning("Could not register som GPIO expander LEDS");
- i0 r [2 G6 E2 R7 Y. x else
! k- s8 d, t8 ]0 ? printk(KERN_INFO "LED register sucessful!\n");
5 _6 e! c/ Z& E: O o$ `. `* j# `
7 y# i' w$ d$ m `6 i return ret;* O0 X! P x2 d1 V
}8 z4 P) n& \& D1 v, l; w. v
4 t% E1 i$ V/ b( I* Ustatic void __exit led_platform_exit(void)
2 D. ?2 G2 m+ U, ~+ n& x& H{
4 @$ o k/ Y* m( O platform_device_unregister(&da850_evm_tl_leds_device);
% r: ]# v. V: m: B ?- Z
; C0 b, v& c3 l/ d2 J printk(KERN_INFO "LED unregister!\n");9 s" ]4 h d! @1 d1 Q1 m% g" n
}
* p4 J' Q9 Y' Z% G" r) s# Z' P2 t" K$ e; Z+ _+ k) u# P
module_init(led_platform_init);
) @" c% ?) g; X4 `, Amodule_exit(led_platform_exit);& U( ^4 P2 c6 o
6 G2 q, ?: e! H! T2 Q# @
MODULE_DESCRIPTION("Led platform driver");
7 \9 t* q9 a% f5 ~# P2 T/ n! V, ?MODULE_AUTHOR("Tronlong");- \3 p+ f' T6 _$ d6 j
MODULE_LICENSE("GPL");- d; X# n0 h) m* _! E& G
% x: `. ~; R4 f0 y; g3 y |
|