|
|
求大神给下面的程序做注解,请稍详细些,谢谢。3 ~ S; _7 Q' R% O6 w
#include <linux/init.h>4 r* X5 R6 H. B' J3 ?
#include <linux/module.h>$ j% S. \, `' G6 Z/ n
#include <linux/kernel.h>( g. ^# u# C' F5 L2 \' K
#include <linux/types.h>
( O- z/ c& b; g/ }8 a; I#include <linux/gpio.h>+ ]9 ]5 u) ? X) y1 o3 v9 v
#include <linux/leds.h>
+ ?% i. J' G5 N9 f$ e% q#include <linux/platform_device.h>
1 E; {" w5 P. s' ?2 r& u2 e6 B3 h# c& x1 U
#include <asm/mach-types.h>2 r# Q4 C& k; @4 ~; k, J O
#include <asm/mach/arch.h>
6 I2 g) { K% @# y5 ^#include <mach/da8xx.h>+ T' A0 J1 u' P# A, e+ r
#include <mach/mux.h>8 @2 u% u" U ]$ }/ \
: m* R( y( T* a7 ~$ U: R#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)% ^8 n. ], Z+ C" q Q" w+ b; ^
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)! h X+ j& e! O4 f0 q
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)6 G4 R, F- j' @5 u
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)' p, I6 J9 Y; h7 E
, M* h- a3 m, n$ p3 h# _/* assign the tl som board LED-GPIOs*/
1 L' i8 j, D% G8 t7 [. w. a9 [static const short da850_evm_tl_user_led_pins[] = {
9 ~. N( h- }. P& |6 I8 R; p% _7 | /* These pins are definition at <mach/mux.h> file */
5 k" v# h6 C/ P N& i4 H DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,7 h0 y! m- \, m- c- P* u" a
-1
2 ]6 y! x$ {; J6 _1 Z: T};/ }( m- U1 _* n s, A5 |
: C& V. m: q P) K" O# k/ b% tstatic struct gpio_led da850_evm_tl_leds[] = {
8 C# u& O) M3 B& F" W1 ^' C6 y' x* q {
$ X7 p0 o% x& W. |1 y) v \ .active_low = 0,
$ ?9 V7 y0 f4 E .gpio = DA850_USER_LED0,
1 O+ L- ~/ \* M3 |% v .name = "user_led0",# O6 x9 h# [6 P- y
.default_trigger = "default-on",3 w9 N9 L# B6 }3 E
},( o/ k- k* N/ O" M; T v
{, o2 ?. x" t* p H
.active_low = 0,# _8 R8 X1 h8 `7 ?0 V) I
.gpio = DA850_USER_LED1,
4 @' Q5 {4 E$ }6 q2 M* A .name = "user_led1",$ S. J+ q* e6 t
.default_trigger = "default-on",
# `" `4 r2 Q% k* H* X, G9 O+ y },4 t' X* ^" T7 K+ b, g# S
{
: K s0 m, K: M8 Y3 m. M .active_low = 0,% j1 f# t; I( _; Y
.gpio = DA850_USER_LED2,9 l" z5 B F+ y6 r7 N6 |
.name = "user_led2",5 m$ c" l; E) V& O! r% ~! w, V8 Y4 V
.default_trigger = "default-on",
8 h4 b0 w# J. }/ i6 } },
) G6 E) X7 |5 l& o* P R4 s {6 S* H: T" L @& @! Q% Q5 I# T% m
.active_low = 0,
, D) _; E$ J4 F' l .gpio = DA850_USER_LED3,
: p6 l# L z+ l. f .name = "user_led3",
2 \/ H& f2 O5 |) d$ _: b .default_trigger = "default-on",6 G& L. R9 k6 Q# J" T
},
" p J5 T I; ]! P7 w% T) _: l};! I' t* ~( c0 @3 w
3 s3 c' c( f. h! U* ?8 Dstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
( O# y0 b: H! \6 O) S .leds = da850_evm_tl_leds,& I. d6 J7 k3 @% U% s( K7 G
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),' k. f6 f& g7 i+ k) [- g" \- v
};
/ F, R" D |2 S9 z; y& p. R9 {- m, e6 i6 c+ P
static void led_dev_release(struct device *dev)
& I" y$ q. R, h* D: {{! B3 w& I8 C8 J$ P5 J
};$ R1 g R* A6 v4 R
% q3 F0 U! M( T' u. y
static struct platform_device da850_evm_tl_leds_device = {
9 W h' O7 l9 v! ~6 e N' W8 S, r .name = "leds-gpio",/ p! x1 ?3 ^. e
.id = 1,
8 o4 ]& g8 Q. L2 I( k8 l .dev = {
! I* I4 P' [$ W( v# o$ H .platform_data = &da850_evm_tl_leds_pdata,: V; [" x9 l; D
.release = led_dev_release,/ x W1 z# R5 {; P, Q" m
}
- ]7 |+ |' L/ z" h: V1 b# w};
$ f) `8 Y/ E. j$ s
+ y' U, u) l1 ?! L: H. {2 s/ Y/ cstatic int __init led_platform_init(void)
' C( I) t0 c0 n8 }{# Q# M$ d- d# H
int ret;4 x* O3 X! z2 }2 {8 d0 Z' V
#if 0
$ @7 C1 E$ M: C% z$ _! x+ x ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);6 w2 N# G; k' F+ k! ~1 J
if (ret)" r# E4 f6 Q3 w; n: H% u' q* C$ }
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
9 i V! L5 ~1 A# @; i7 f3 [+ P+ y "%d\n", ret);
V9 Y( u, Y! G+ d8 V/ `+ |* B4 a#endif8 \, f' u5 b( ^" {8 v
ret = platform_device_register(&da850_evm_tl_leds_device);' h% I) I/ O: |* O7 n/ m; l( C/ R
if (ret)
8 ?; Z' B; m2 H9 I J pr_warning("Could not register som GPIO expander LEDS");
- I" [# c* Q6 A7 c. m* M6 w else
. i2 F5 e* r- Z D. a printk(KERN_INFO "LED register sucessful!\n");; ?4 b: B, T9 K6 m% Q* O* X
) ^0 k7 ^% x( j4 k, e/ v; V, }
return ret;
8 n3 F" a- ^& E$ K}$ U+ z% w. w3 h) t& u; I# ~
, K) \7 b& N, u# A. F: k" c) fstatic void __exit led_platform_exit(void)5 v8 V3 e& M8 g. y' G: Q1 C% E
{
: Q8 `: x: f. ~ platform_device_unregister(&da850_evm_tl_leds_device);
3 z4 L, }7 U0 s6 P" D' h
; Z2 b/ K/ ^; n2 ` printk(KERN_INFO "LED unregister!\n");
5 U% J; E5 x% F W3 j0 m) K}. i7 S; g: M2 G5 ?5 k. L) b
0 m) A, h. O* p/ y- B1 z; B: \
module_init(led_platform_init);
5 b. c6 q9 E6 h t% G! Jmodule_exit(led_platform_exit);
" o2 F& n- j* v3 P+ X" o8 Y2 M7 e
MODULE_DESCRIPTION("Led platform driver");
9 Y1 w& b3 @; p) w$ K% fMODULE_AUTHOR("Tronlong");3 L& S2 m, n/ O7 |, B$ A
MODULE_LICENSE("GPL");, y" G5 C' k9 B# }% |
- c5 ~, v* t* V* Z |
|