|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
: `& k1 C6 c5 t4 k0 m#include <linux/init.h>8 c+ J" R. _% c* k! L1 \
#include <linux/module.h>
" v0 N2 V5 a- E2 H4 O( g#include <linux/kernel.h>
, l+ v1 t7 U) w& x#include <linux/types.h>
. F/ R& N% m+ C#include <linux/gpio.h>
$ ?1 E+ h# w l0 n- V#include <linux/leds.h># X0 I9 o: s- X
#include <linux/platform_device.h>% ]) G0 g, B4 T, b/ K3 U
7 P$ ^, Q; o4 W, i. O#include <asm/mach-types.h>
$ O2 [5 [+ C$ \#include <asm/mach/arch.h>
7 q9 t$ x* J6 @( w2 B/ V#include <mach/da8xx.h>/ B( l. D" z3 L1 T$ E7 M; L4 R. M
#include <mach/mux.h>
6 d9 K" S) t6 _+ [8 }2 d$ Q/ `2 Q/ m; u. P
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)4 F6 |9 }* ^$ p
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)* \* y: X5 E; }1 ~; U
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
8 m2 a# @3 @: v/ g: i#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
# K: L/ \/ X. r
I: |5 s3 w7 g3 J* z R# y/* assign the tl som board LED-GPIOs*/
2 @8 [! ^1 T* U0 i4 sstatic const short da850_evm_tl_user_led_pins[] = {
/ M& d7 V/ {7 B7 r+ J+ F /* These pins are definition at <mach/mux.h> file */
( o5 K O5 ~8 s. o; F% h4 ] DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
; k$ L6 P1 M$ M4 v! c -16 F- c2 J4 S2 c3 s6 V! [
};
# \5 }$ I4 [4 e5 j; [+ S+ B, R" G! P# x3 i) H% S- ]: @
static struct gpio_led da850_evm_tl_leds[] = {: u! ~$ w- M" `! z
{1 [' C1 R3 y0 O6 l$ C
.active_low = 0,
) Y) w% h T. n9 z& R" r .gpio = DA850_USER_LED0,
, v, f1 f. m& C, k+ D .name = "user_led0",
/ A, @5 o+ A z+ M3 I .default_trigger = "default-on",; L, D' C2 D. T& d% }) @
},' v% {4 _) ~+ V3 o; [, R
{
' ^' C |& ]. m% \% `' U a .active_low = 0,
7 ~. F# H. U" k7 Z8 l3 ~. L9 d .gpio = DA850_USER_LED1,* j$ t! l# f4 p* }$ v# r
.name = "user_led1",! S" W" K% K# B9 w5 T
.default_trigger = "default-on",; b5 `4 v0 D7 }
},1 d$ d* P8 Y! Z. ]- H I
{0 s- e% q2 P, c5 W' }* n. c1 _
.active_low = 0,! @, }0 W7 P' B" J' t
.gpio = DA850_USER_LED2,
4 P3 H3 N W5 _, M9 D! { .name = "user_led2",/ C; g+ F1 N# P) r# ~
.default_trigger = "default-on",
, z' c) D3 t% y# |/ ~ },
" ?/ w) P* }( o {8 q' W$ d' V3 z3 ^+ g# k" \
.active_low = 0,
5 l4 g; W& S8 t/ d, A4 n .gpio = DA850_USER_LED3,6 j# f5 W6 F5 Y8 r6 v7 u
.name = "user_led3",
4 l0 b: L! Y+ g8 f7 J2 ^ .default_trigger = "default-on",
x! d0 K' ]/ O0 }% R( ] },
! d. v6 u e! {' Z. P6 w};
* Z1 T. T9 r# t: a5 B; I! m+ ]
p7 q% d3 K' Cstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {" E2 w: o. i6 c& i) ]
.leds = da850_evm_tl_leds,/ H3 p* P7 Q4 X
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
# L6 q! D4 k3 T) L1 j7 { B};6 p1 G) |0 W/ j6 F, k
' ^# V ]& b% L2 [" Hstatic void led_dev_release(struct device *dev)5 J8 B: m7 g7 l7 `1 d) d3 C! d- }
{
# o$ r& y* R* d6 a3 e};
3 O7 X4 e) ]; |$ Z9 j# z/ K
2 A4 @, W- o8 kstatic struct platform_device da850_evm_tl_leds_device = {
' C7 p6 R w. h6 b! O6 ]7 l .name = "leds-gpio",
1 f- `9 a$ y) o0 I) W4 a4 ~/ R! q" |: e .id = 1,1 S2 n8 N9 c4 |/ K; y: N2 p B6 }6 b
.dev = {: X4 w% Z! G( x( S
.platform_data = &da850_evm_tl_leds_pdata,
8 N" W8 g" T$ s- l6 } .release = led_dev_release,) i0 x6 ?2 k: }" d0 `% A
}
7 @4 [" i5 d' G/ t};1 o8 b7 F/ Z' {8 }! \, H
* T, e0 Z/ R8 D# O7 astatic int __init led_platform_init(void)9 j4 i( _! u8 O3 Z0 C: t
{! C: h+ W. t) M
int ret;& l) _, b g" Q& W) S
#if 0
+ H. v; b/ Y* b/ n/ D; | ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
5 C3 k) ?: D9 ?) \) C E' k if (ret)
# N7 `3 A# l h; b% d& p pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
: V; c& e: g5 l7 x "%d\n", ret);$ [8 U1 W B: z- h
#endif
- v3 y( c$ \# u! m" D9 L ret = platform_device_register(&da850_evm_tl_leds_device);* B' b/ e/ s& s+ R& T
if (ret)
x5 h( [* q @( m pr_warning("Could not register som GPIO expander LEDS");. v0 m2 y3 U- U
else
+ [- \, `9 J/ Y* g$ k2 K printk(KERN_INFO "LED register sucessful!\n");8 V! g. g8 J3 w) H8 \/ _1 B- @
2 d* z8 t# T ]( x
return ret;
$ G, |, C, p' s5 P}
) v4 D' _+ W0 M
. X) J$ m$ d7 o$ f+ Xstatic void __exit led_platform_exit(void)# o& p! N ]& B0 W$ A3 z) S
{
/ |- A4 P' \ l' `9 T$ E platform_device_unregister(&da850_evm_tl_leds_device);
' h7 u. A1 H0 n* Z. e" [7 r4 H: i @( w5 r
printk(KERN_INFO "LED unregister!\n");
* ~ e2 |8 Q' w3 K5 r5 o7 S3 K}
$ b: e' U; C3 L5 n+ c0 @1 f; V' H) |5 P, y% I' X/ L
module_init(led_platform_init);
/ F+ h. Y6 e9 D9 S% @ B( Qmodule_exit(led_platform_exit);
3 O: A( `! J' _2 F4 p. K; T# c$ P3 Q7 r+ G( S" K- D) o
MODULE_DESCRIPTION("Led platform driver");
- e" M6 V3 w8 W8 P$ t' M- D# Z1 RMODULE_AUTHOR("Tronlong");9 {& S& L8 P* w
MODULE_LICENSE("GPL");" P4 I, t7 X. B0 ~- Q# T
+ ]3 Y. G5 r3 O/ R6 d |
|