|
|
求大神给下面的程序做注解,请稍详细些,谢谢。( T9 ~1 ~, e8 i
#include <linux/init.h>9 \# ], P* L S! | L
#include <linux/module.h>
1 y; S$ A! g( Y. G5 `( p; F#include <linux/kernel.h>
; N [: J. q/ r6 ?. E! E#include <linux/types.h>9 b. K. N1 b- B- H4 |! L2 f
#include <linux/gpio.h># E3 b% Z) m7 w i, D: a
#include <linux/leds.h>. ]' A# s- \7 c& w6 a8 `
#include <linux/platform_device.h>! c# O1 B" ^. ]! [+ J
6 ~& [; m" H' _0 k( O/ |# ^& k8 l#include <asm/mach-types.h>
: u2 [ g) P) q" o2 G# R6 o#include <asm/mach/arch.h>* L! B. n- ^ U' L* A, Z2 g
#include <mach/da8xx.h>
7 }! T# b$ t% V1 ]; z" r#include <mach/mux.h>, O8 G% S. _: r1 ^! n. A
+ Q1 \9 @) @/ l# Z
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)5 ~" X i# f, i( F9 Z% F- u# [% f
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
5 a% R" D( V% }/ o& @2 k4 [! D9 h# O6 f#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
0 ^' ~: o1 q6 C9 V8 w2 | X: q#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
' U5 \8 q& `" H6 z) W0 k! p. W& @" `3 s( Z+ L' G) h
/* assign the tl som board LED-GPIOs*/
: d: c3 \1 C* D) _( cstatic const short da850_evm_tl_user_led_pins[] = {
$ j: Y7 \9 T3 d6 p# M /* These pins are definition at <mach/mux.h> file */0 R; |/ o7 j# L7 J' N+ _/ N
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,, P6 y2 T: |" s
-1, `# @, P) u4 z4 I. n4 g$ a
};7 [* Q6 E7 u6 d) S# G
- _1 a& i x" F6 k$ a _
static struct gpio_led da850_evm_tl_leds[] = {3 d9 ]7 x& q: ?, ^" G4 D
{: f0 z4 q1 z2 d* h
.active_low = 0,1 @3 X) Z. M: m) ?- k' T; \5 O
.gpio = DA850_USER_LED0,
7 e, {5 M3 ?* v' a* w" H b! j4 p q .name = "user_led0",
9 k9 U3 N& K! l2 c: @- d3 B5 w .default_trigger = "default-on",
N! N9 Y5 b0 V8 e O" m' O2 p1 o },# v1 z9 p s7 W5 \4 Z4 L, J! `
{
' |- h0 C7 `+ J( J. ]; _/ [' e% ` .active_low = 0,
6 Q9 R3 U; e& L& `3 c .gpio = DA850_USER_LED1,0 M: z1 z* X; j: ?
.name = "user_led1",
. g8 ]* e, q% A$ Q* r4 j& w .default_trigger = "default-on",
1 \% q" [& c, L2 Q2 L },7 }% E) u) ?' r( l4 S8 K7 h
{
0 Y( @4 ~5 E6 y .active_low = 0,; \* q5 @. L$ o7 X1 x
.gpio = DA850_USER_LED2,
( r9 k# N5 P" S1 d& ^" g .name = "user_led2",
1 w9 o4 A2 y/ ?# T% l .default_trigger = "default-on",5 I: [; l; Z2 u4 P5 ~* a0 ?
},
6 M$ y. a" i/ c0 l; c! p( { {
' s; G2 U( k+ a% Q0 p' y& u. b q .active_low = 0,' b2 s/ l8 ]+ _/ M0 I
.gpio = DA850_USER_LED3,
' V7 w0 Z( e T" w. M0 m1 x .name = "user_led3",: W* f) B; E! w) i- m* T9 ^0 Q
.default_trigger = "default-on",
' k9 [' \3 e& b2 S; c },5 h3 K8 T( h3 W7 e0 O5 X6 s
};
7 a. `5 V! A' K3 U- L# H
8 V% m# z0 G7 z/ E( @static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {9 U4 A% \5 K u) z6 z
.leds = da850_evm_tl_leds,' S0 @4 {* x: \9 k5 A7 [
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
! K- \) H: S5 y v$ S6 p1 c" y};( I% P; x! L% M
, I' A3 x- O! v0 v, p0 K; G: l/ U/ w# y
static void led_dev_release(struct device *dev)
* X% J# c+ W& |8 g: T% D{
" @* n, x2 Z8 M$ Z};
+ U, b/ y8 w* d# i3 Z3 e( t$ n. u2 B7 _5 Y, o
static struct platform_device da850_evm_tl_leds_device = {
- f" l( s! p/ Q* I .name = "leds-gpio",3 L# R. _! i' [' v- E( Z! ]$ _
.id = 1,8 k1 U5 B' ^, h2 X8 B3 f
.dev = {
. E( g, h8 @: s6 C) V .platform_data = &da850_evm_tl_leds_pdata,
6 W- S1 `6 B; C* f5 s .release = led_dev_release,
9 i3 o8 [6 w7 n5 J8 T, }# y2 g }& E0 ?, r7 A, O8 `7 [8 ^* _3 g
};
+ t. f: x k: o* i+ ]9 M2 _0 ^: {# K3 t: T& \
static int __init led_platform_init(void)
1 U# C S; j2 j u! D. L. {{
% W( E- c0 b1 \8 o6 n int ret;6 E- ?) z0 m3 R
#if 0
: b. S" g \9 {! y; |6 J2 Q ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);* o( ], g) g9 O" h9 H
if (ret)9 T. O9 Z K0 E5 Z9 t$ ]
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
( E# T: ]2 h: v1 @, V/ Q* j "%d\n", ret);* s( p9 B* v% u2 [% S8 p; U+ m
#endif
! t3 l2 M$ @6 M# D E* ~6 {1 L ret = platform_device_register(&da850_evm_tl_leds_device);* `9 p% ?. w9 ]9 J1 u/ C
if (ret)9 r) l% z- d& x( u' d
pr_warning("Could not register som GPIO expander LEDS");1 E$ I+ v( _1 {& T6 R- V: {
else
! ^' t# K3 C. [6 w! a/ ]- S/ s printk(KERN_INFO "LED register sucessful!\n");$ O8 v5 s, Q, ?1 X
8 j: I0 X1 d) E' G6 e return ret;0 J& U; o; v5 W
}3 P. r3 P0 M& N* s7 }! @
* M+ v3 D" I- R; v) K# C
static void __exit led_platform_exit(void)
8 ?( Q, m8 Y' |9 C2 B* z{
1 S) c( }8 P; a( C* W, i* T platform_device_unregister(&da850_evm_tl_leds_device);
1 H' R; M7 b! {& [
9 q6 b1 J& Z ?9 k; x2 d printk(KERN_INFO "LED unregister!\n");
9 q, I0 g' @* ?5 E% }: _}! Q6 P ~( l/ t& C2 m+ {
8 \1 P: w6 G) p9 y& ^% g! Dmodule_init(led_platform_init);/ O6 j* E. _6 ^. _; s: {
module_exit(led_platform_exit);
: I- L9 {5 k3 e# K- l8 g; a: L# M/ ], M; b% u Q
MODULE_DESCRIPTION("Led platform driver");
3 W& c. H6 u3 \MODULE_AUTHOR("Tronlong");
6 L) q Z" o( n, y3 j' o6 \MODULE_LICENSE("GPL");/ f6 i! G# k) I- h! G* U# q; m
& ^' C- C& f5 k8 u; T. R: G. i |
|