|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
* o3 S, }9 p' X* h#include <linux/init.h>
& z- g/ Q( P; z4 ~, v; D- I) ^#include <linux/module.h>
4 \4 ^+ b7 M( V" |+ u" t- M#include <linux/kernel.h>
- T2 A- s. f8 R# Y. k#include <linux/types.h>2 U: Q4 X2 I9 u* B% R
#include <linux/gpio.h>6 c) T% J! @' m5 E( \ h& k
#include <linux/leds.h>
7 u$ f) i% d1 \& `8 g7 T7 u#include <linux/platform_device.h>
, Z/ m) @% ]& O9 N1 f. j+ f% o# u9 g2 a4 F5 u B& s) M
#include <asm/mach-types.h>5 X4 ~1 ]) n) j7 y5 V2 s) e
#include <asm/mach/arch.h>5 G1 H8 J% c" |0 p
#include <mach/da8xx.h>
8 C$ p1 J" k- ], P+ Q#include <mach/mux.h>
( A4 M2 ~& m% n) d+ Z' o" V; O$ J" X' C) D& [- ~
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)9 L3 q. }* L% [: e! C- t
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)9 D+ W) |8 b2 K `
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)1 q5 m6 @4 G+ R7 C) f3 m: {
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2); D& O/ K! J. _' g
H' p% X; R; } V% \
/* assign the tl som board LED-GPIOs*/7 F4 ~/ \) q" ], `5 H+ j" v
static const short da850_evm_tl_user_led_pins[] = {% S$ }0 L+ m ?; |% {1 ]' }' m
/* These pins are definition at <mach/mux.h> file */
3 N$ ?% d0 }' e, l7 d$ D DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
( _0 S8 _( n p. f+ ?# m, p -1
; M- [ d+ n$ O$ u4 j( B! u};- j3 Q' O; K) l: T+ q7 [$ {
6 }, B5 \: l6 T, }4 {9 g
static struct gpio_led da850_evm_tl_leds[] = {
: [& ] u9 s0 n8 c$ J {) X$ }& Q3 t8 I+ k( @3 O
.active_low = 0,# p5 v) u v6 \% \. ^# E
.gpio = DA850_USER_LED0,. e! G* F9 H# M% P; ]8 f4 l
.name = "user_led0",) Z) [7 L5 Z& o
.default_trigger = "default-on",
, c! m+ E: c2 V! K },+ _8 D' M* M0 }1 m
{+ H+ l1 \+ @; u' i0 i( H- I
.active_low = 0,3 Y" T% Y: p# T# w) }: Q" H
.gpio = DA850_USER_LED1,& x/ D9 W7 O, Y* P
.name = "user_led1",
: C6 ?* F" f4 ~ .default_trigger = "default-on",
$ ~2 Z0 g# z, n/ |; H8 t1 X },5 f; q* D: D! b0 v ~
{
1 r# B$ Q: o) g7 Q .active_low = 0,: [6 |' t& \: i- T7 ]8 o* S3 x Z
.gpio = DA850_USER_LED2,3 _( @* ?2 V( B6 Y
.name = "user_led2",7 O; i( K8 J9 X9 x( K
.default_trigger = "default-on",
2 x4 u" A0 J5 P% b4 s7 G },
. C; o$ m: j, Q$ m2 @6 W5 I0 H/ e {
% J4 B' q2 C4 p6 N. r" k1 P .active_low = 0,2 k, }. H7 |' e" x
.gpio = DA850_USER_LED3, c' d+ x3 Y7 I [
.name = "user_led3", t1 V* p4 R# |0 c
.default_trigger = "default-on",# o3 P5 X& [; {. X3 S2 g5 k- D
},
0 I/ [6 `8 E6 _ T* R4 h# o};
, I( V. D2 H! H' C' m/ N, o4 P% n$ `
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {, G: ^/ M4 Z) y. `
.leds = da850_evm_tl_leds,
6 q" k8 B. `- m. U9 H4 n+ D: ~/ d .num_leds = ARRAY_SIZE(da850_evm_tl_leds)," c& D& s! S* Q7 Q1 X2 ]
};
5 ^8 T, G, T. b! C7 y- K* I z* j
+ S" {4 h# k: ^6 k# B$ Lstatic void led_dev_release(struct device *dev)9 E x6 m d; ^2 \3 Z6 L
{
& n; W( {! T7 W' H( }) K- P};
* y0 ]' b- V- w) Y# x$ b- N! h% c. U) d1 o
static struct platform_device da850_evm_tl_leds_device = {
9 k4 {+ }2 x8 i- p& f3 d* H .name = "leds-gpio",; ] @1 h4 W D1 e
.id = 1,0 f' ]& @+ G* d0 G0 W/ {0 K
.dev = {( z" D; y( D& K1 }- R2 B& z
.platform_data = &da850_evm_tl_leds_pdata,7 l! T" b: S& _ J
.release = led_dev_release,
, f, W8 Y/ |" y }1 ?, j1 b3 {$ w1 ]
};$ E5 F! `+ l# g, b
- Q# x4 f& j7 q# y3 N, I( H0 rstatic int __init led_platform_init(void)
6 l: L* _$ g: } H# H1 J. V: G{
, F% @. e! V: I6 Y; y5 J3 O int ret;
- f/ i4 A% d6 B9 H- R) g3 J#if 0 u. S1 R; x- a7 H8 x9 Y
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
- S. Z2 z: e+ p [ if (ret)
$ Q% U- }) M& }+ }' ^ pr_warning("da850_evm_tl_leds_init : User LED mux failed :"5 _( S7 F* j, r: X+ @6 [" ^
"%d\n", ret);
0 a& Y% [7 T" c; f4 J! f$ q#endif
, K& P7 a$ g) \4 U3 h# E ret = platform_device_register(&da850_evm_tl_leds_device);
* O9 E7 t! X) z7 J, q) P3 @ d if (ret)0 W! H$ D( b$ w$ `+ @* Y0 ~
pr_warning("Could not register som GPIO expander LEDS");
! B5 E* H/ q% \" a else
* L; m2 g- V$ h* R+ d printk(KERN_INFO "LED register sucessful!\n");
$ f2 y# d5 k* \- t
6 {0 M* M8 u* o% Y/ X return ret;
x6 T, e- T$ ~; z0 L}
- J( ]! @3 u# `* M4 r- s2 w
8 `/ f8 U2 N+ q( ^+ a' Fstatic void __exit led_platform_exit(void)- Z% D% Y& J" d. Z: B+ K7 w1 D6 L
{
# c2 r. \: I h0 C platform_device_unregister(&da850_evm_tl_leds_device);
8 A0 W9 x7 U' D; Y
: a- _" Q# l8 Y; C# o printk(KERN_INFO "LED unregister!\n");
3 s8 E6 e+ ~! M4 X& |}# x* f4 R( H5 n3 Q! l& {4 `
5 J& r9 c) n# nmodule_init(led_platform_init);1 F. _1 \, S/ r: z4 Y: w/ k; Z
module_exit(led_platform_exit);
, b. C% I; Q3 ]
) F; t' v A9 W4 @MODULE_DESCRIPTION("Led platform driver");9 n! G' p# M7 [' B% J4 ~# o
MODULE_AUTHOR("Tronlong");
) M$ W0 L: y/ f% W# e8 A# @/ mMODULE_LICENSE("GPL");
% x; R3 C; q# C/ Z0 c8 m$ U7 Z( l2 W
|
|