|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
# |, J- E/ R: G#include <linux/init.h>
6 ]9 y6 D+ {% M1 D9 z; F#include <linux/module.h>* v. P3 s; m8 b3 r% [
#include <linux/kernel.h>1 K3 C! v) t/ R# {1 q4 Q: O
#include <linux/types.h># U, ?3 d$ J y* }4 w6 z# d f
#include <linux/gpio.h> S8 T8 b, U) R' h! Y
#include <linux/leds.h>
J( L1 c6 [ n e6 A#include <linux/platform_device.h>/ Y2 {5 C2 c2 ]6 g. @- n% ~
$ U6 e" }. G/ n- o. e9 R" q#include <asm/mach-types.h>
, I1 h+ v6 a6 U' n- P#include <asm/mach/arch.h>
`9 {5 h- ^8 {#include <mach/da8xx.h>
! q: h" m: `3 g2 f$ P. z0 X#include <mach/mux.h>1 F2 M7 k1 |' S5 M6 ]
8 O; _& X$ s _: ^! |4 a0 u
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
( y$ b0 d0 y$ `7 J8 @8 F9 _$ z' c( I#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
- }( V1 h; V. F/ w" g#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)2 w! v) m2 o3 F1 X9 e
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2) \- i% A$ M$ O7 x
7 K1 c% H& _8 t0 w' Q$ S; q, ?/* assign the tl som board LED-GPIOs*/
6 w. |8 q& y/ ^4 T% c) Cstatic const short da850_evm_tl_user_led_pins[] = {1 U7 i# ?2 p0 m1 ^
/* These pins are definition at <mach/mux.h> file */
% d+ }% O" J9 s# @1 x7 v DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
. L) i" K4 @9 E" U -14 |7 L( A; V9 Z* O7 |: g
};
* J2 c' {( P! I+ j- l* Z
& Z5 G' H6 P4 m8 Estatic struct gpio_led da850_evm_tl_leds[] = {. I5 v, o3 [- c. y( g |
{/ T% A* C Z+ r6 B
.active_low = 0,' q8 K# p4 n6 v5 g: f- V" u1 T
.gpio = DA850_USER_LED0,) l4 C2 u) H& j H5 J6 h. d E
.name = "user_led0",
: b- S5 a6 u" s! I7 t/ I+ r .default_trigger = "default-on",7 b. P/ w! v/ T2 }7 f. M
},
5 m6 H d" M, l' S. ~! L { e) i4 v. e0 f$ ^
.active_low = 0,
4 ? _2 a U, S* W .gpio = DA850_USER_LED1,* q, t4 D m% N- _' ?5 \ H
.name = "user_led1",1 ^% T* L7 \7 x
.default_trigger = "default-on",. p6 W# `8 Z9 n, y" n- y: E3 c, A# ?
}," W, @2 x3 u/ Q: ~1 Z. ]$ Y
{# I# M2 V) d- N9 F0 j
.active_low = 0,/ L, Z5 Y2 \8 {! O( x ~
.gpio = DA850_USER_LED2,
+ Z" @& N, i2 `0 ?2 | .name = "user_led2",
; s+ J% u3 A6 [; M. A8 k .default_trigger = "default-on",
6 X; L7 H2 C7 T },3 S$ w) [ n9 O4 @- ?# V( y5 a
{
( [% N# r8 A7 Z- `) R5 t- p .active_low = 0,. C# A A. _- i7 t0 m8 R$ K8 n
.gpio = DA850_USER_LED3,7 U; r8 r; i* U' \
.name = "user_led3",: B/ d+ r! f4 U* x4 T) S
.default_trigger = "default-on",
4 x; X8 e" B- i) A9 `, V },; v; R; d7 H y6 \3 e/ l! A5 B
};# y1 e9 }# Y) j/ Z- d2 x5 c# B
1 ^ e/ ^ @! i. f3 z) A/ |+ tstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
5 g. q$ Y: w" P a' x .leds = da850_evm_tl_leds,
! v- S, }8 M! K- j" ~* S5 D* r .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
# R" I4 V2 J* Q) v};
- A( C) k$ ]- C8 Y. W4 K# V& @7 _4 u) x, g; N
static void led_dev_release(struct device *dev)' J8 d+ Z+ u Z0 ?5 I8 I
{/ `8 {7 i, J& f, a1 l+ i
};
, d: N4 V, v1 K/ A+ I
% |2 E" ^8 a+ i- Dstatic struct platform_device da850_evm_tl_leds_device = {
# R! |1 `' n* U4 b1 @6 V) l+ x .name = "leds-gpio",
4 z" J( t9 K9 w' [. t& ~7 V .id = 1,* p& O, i3 N# l# B/ N
.dev = {/ `- `3 \6 v7 b, j: ^" a
.platform_data = &da850_evm_tl_leds_pdata,: d( i* p) X( l- Y! D( {
.release = led_dev_release,
$ {$ D9 I' f! S1 K. Q }
3 J3 w( o# Q, e4 f};4 c: [4 J d; M+ U5 [+ k
; H8 E1 I! O$ N! c9 }
static int __init led_platform_init(void)# v8 S# @& y* z5 V4 D
{
3 l: Q$ J% y; `$ E" G. [ int ret;
' m/ s" O3 |- U#if 0, a. j# P; n6 e7 Y4 B
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);: f& {4 o9 g) P, p0 L4 e- ]' o9 J
if (ret)8 Z' |4 A& H$ F R
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
3 h" t9 e/ r/ j4 C; g "%d\n", ret);
& ]! n6 s: j4 N% ]7 J#endif4 a) w% Q* y* h/ W0 {% J* l
ret = platform_device_register(&da850_evm_tl_leds_device);# b1 |- A7 [9 U) u
if (ret)4 a5 U2 f! E, l0 q! b
pr_warning("Could not register som GPIO expander LEDS");
( j& a! f0 j2 M/ V$ @ else
5 F: m& U# R! A printk(KERN_INFO "LED register sucessful!\n");! \) h( B2 [/ F1 l- C; u
& Q' _! }6 o$ }# v
return ret;4 }$ L% E7 a( i5 g
}
" R; A- r* h& M4 O6 E
/ V# M8 Q6 U Lstatic void __exit led_platform_exit(void)
& N1 U% `' ?' _' W* E{
: d4 A% L3 C( y" l9 K; i platform_device_unregister(&da850_evm_tl_leds_device);
4 a& M P1 g: {/ \% Q
4 I0 X7 u: Y. ~4 C0 G printk(KERN_INFO "LED unregister!\n");3 b% ^& t; U+ o
}
) B, \8 h7 Y7 p0 V* o. L: @$ J5 r+ Y& F, H1 `; }# I( U
module_init(led_platform_init);0 P* v; n8 h7 J0 B p# X
module_exit(led_platform_exit);$ `* U B1 ^7 N4 x5 W! W: N
( {9 A8 O* z7 d: q$ {+ z% J3 d
MODULE_DESCRIPTION("Led platform driver");/ M; g% m. S$ O" P1 `7 C! v
MODULE_AUTHOR("Tronlong");+ Q1 x* w: `9 G# L5 @% }, Z" O# E
MODULE_LICENSE("GPL");: K* Y8 N+ |# V c& ^1 @
7 b5 B) V: u0 z
|
|